Support has been upgraded!
The Support Forum is closed. Not to worry! Providing the top quality support you expect and we're known for will continue! We're not ending support, just changing where you submit requests. This will provide you with the best experience possible.
Premium Support
Have you purchased an addon for Connections such as one of our premium templates or extensions with a valid license and you need help?
Please open a Support Ticket in your user account.
Free Support
Are you using the free Connections plugin? Don't worry, you are still very important to us! We are still providing you with the same high quality support that we're known for.
Please open a new support topic in the WordPress support forums for Connections.
- This topic has 17 replies, 6 voices, and was last updated 10 years, 9 months ago by
Steven Zahm.
-
AuthorPosts
-
10/11/2014 at 2:11 pm #306836
Robert Clasen
ParticipantHi,
We want to have a separate page before any records are displayed. The way it is now (using cMap) is when we go to the directory page where the shortcodes are, we start displaying business alphabetically. We’re having complaints about this, the business that don’t start with ‘A’ are not displayed right away and they feel the ‘A’ records are getting preferential treatment. So what I’d like to do is have the directory homepage just have a search on it with no records shown yet. Then if I search on say company name and put in XYZ, all the XYZs return. Is this possible?
Related, let’s say we offer searching on Company Name, City and Zipcode. Is there a way we can have those search options in a pulldown or radio button format?
Thanks!
Bob10/13/2014 at 10:43 am #306890Steven Zahm
Keymaster@ Robert
It is possible not to show any entries until a search is performed…
Install the Code Snippets plugin.
Add a new snippet with the following code:function cn_initial_search_filter( $posts, $WP_Query ) { global $wp_query; if ( ! class_exists('cnTemplatePart') ) return $posts; $shortcode = 'connections'; $pattern = get_shortcode_regex(); // Grab the array containing all query vars registered by Connections. $registeredQueryVars = cnRewrite::queryVars( array() ); foreach ( $posts as $post ) { // If we're in the main query, proceed! if ( isset( $WP_Query->queried_object_id ) && $WP_Query->queried_object_id == $post->ID ) { /* * $matches[0] == An array of all shortcode that were found with its options. * $matches[1] == Unknown. * $matches[2] == An array of all shortcode tags that were found. * $matches[3] == An array of the shortcode options that were found. * $matches[4] == Unknown. * $matches[5] == Unknown. * $matches[6] == Unknown. */ if ( preg_match_all( '/'. $pattern .'/s', $post->post_content, $matches ) && array_key_exists( 2, $matches ) && in_array( $shortcode, $matches[2] ) ) { // Parse the shortcode atts. $atts = shortcode_parse_atts( $matches[3][ array_search( $shortcode, $matches[2] ) ] ); // Remove the cn-image query vars. $wp_query->query_vars = array_diff_key( (array) $wp_query->query_vars, array_flip( array( 'src', 'w', 'h', 'q', 'a', 'zc', 'f', 's', 'o', 'cc', 'ct' ) ) ); // Show the just the search form w/o showing the intial results? // If a Connections query var is set, show the results instead. if ( isset( $atts['initial_results'] ) && strtolower( $atts['initial_results'] ) == 'false' && ! (bool) array_intersect( $registeredQueryVars, array_keys( (array) $wp_query->query_vars ) ) ) { // Add return = true to $atts so template part are returned instead of echoed. $atts['return'] = true; // Enqueue the CSS and JS. We need to use the action because we're hooked // way to early in WP to use wp_enqueue_style() and wp_enqueue_script(). add_action( 'wp_enqueue_scripts', array( 'cnScript', 'enqueueStyles' ) ); // Add action to enqueue Chosen. add_action( 'wp_enqueue_scripts', 'cn_enqueue_chosen' ); add_action( 'wp_print_footer_scripts', 'cn_init_chosen', 999 ); // Passing the shortcode $atts incase there are any template part specific shortcode options set. $category = cnTemplatePart::category( $atts ); $search = cnTemplatePart::search( $atts ); $formOpen = cnTemplatePart::formOpen( $atts ); $formClose = cnTemplatePart::formClose( $atts ); // Create the final output. $replace = $formOpen . $category . $search . $formClose; // All returns and tabs should be removed so wpautop() doesn't insert <p> and <br> tags in the form output. //$replace = str_replace( array( "rn", "r", "n", "t" ), array( ' ', ' ', ' ', ' ' ), $replace ); // This needs to be wrapped in a div with an id of #cn-list so the CSS styles will be applied. $replace = '<div id="cn-list">' . $replace . '</div>'; } else { // Rewrite the $atts array to prep it to be imploded. array_walk( $atts, create_function( '&$i,$k','$i="$k=\"$i\"";' ) ); $replace = '[' . $shortcode . ' ' . implode( ' ', $atts ) . ']'; } // Replace the shortcode in the post with something a new one based on you changes to $atts. $post->post_content = str_replace( $matches[0][ array_search( $shortcode, $matches[2] ) ], $replace, $post->post_content ); } } } return $posts; } function cn_enqueue_chosen() { // If SCRIPT_DEBUG is set and TRUE load the non-minified JS files, otherwise, load the minified files. $min = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min'; wp_enqueue_script( 'jquery-chosen', CN_URL . "vendor/chosen/chosen.jquery$min.js", array( 'jquery' ), '1.1.0', true ); } function cn_init_chosen() { ?> <script type="text/javascript">/* <![CDATA[ */ jQuery('select[name^=cn-cat]').chosen(); /* ]]> */</script> <?php } add_filter( 'the_posts', 'cn_initial_search_filter', 1000, 2 );Save and activate the new snippet.
That should do it.
re: Related, let’s say we offer searching on Company Name, City and Zipcode. Is there a way we can have those search options in a pulldown or radio button format?
That too is possible but would require custom coding that into the template. I can recommend i dev if you would like to pursue that. Let me know.Hope this helps!
10/13/2014 at 10:51 am #306891Robert Clasen
ParticipantFabulous Steven. Yes, please send me a dev that could assist in this please.
10/13/2014 at 11:13 am #306894Steven Zahm
Keymaster@ Robert
I just emailed the dev. He’ll stop by this forum thread so you and he can make contact.
10/13/2014 at 2:46 pm #306928Joshua Kornreich
ParticipantHi Bob,
I’m the developer Steve mentioned. I won’t be taking on any Connections work for some time. I will let Steve know if I com across someone who can fill this role.
Best,
Josh10/13/2014 at 3:30 pm #306938Robert Clasen
ParticipantSteven, I’ve downloaded Code Snippets and inserted the snippet and activated it. When I go to the directory page it looks the same as before, the page displays all records (the page has the [connections…] shortcode). From what I can tell (I’m no programmer) the snippet should run on any page with the connections shortcode, right? Or am I skipping a step? I’m happy to give you temp admin access to the site if that helps.
Bob10/13/2014 at 7:35 pm #306945Steven Zahm
Keymaster@ Robert
Apologies, I forgot a key instruction. You need to add
initial_results='false'to the shortcodes so you have something like this:
[connections initial_results='false']02/24/2015 at 5:10 pm #320617chris429
ParticipantI have added this code to my site and the results are not showing on page load until the search, as expected.
However “uncategorized” is showing in the drop down list of possible search selections. I do have show_empty_categories=’false’ and exclude_category=’1′ in the shortcodes. I’m still testing and only have 2 listings in the tool, both are set to category 2. And when the results show, uncategorized is not in the list on the left side.
How can I get rid of uncategorized in the drop down? (Market is my default template)
02/24/2015 at 8:12 pm #320633Steven Zahm
Keymaster@ chris429
It appears you may have fancy quotes used in your shortcode. WordPress does not support the usage of fancy quotes in shortcode. If they are there there were likely introduced by copy/pasting from a web page into the Visual post edit. If this is the issue… do this.
Edit the page where you inserted the
[connections]shortcode and its options. Switch the editor to the text tab. Now, delete all quotes and retype them. Additionally if there are any HTML tags in or around the shortcode, remove them too as they will also break the WordPress shortcode parser.Let me know if that helps!
02/24/2015 at 8:24 pm #320634chris429
ParticipantThanks for the suggestion. I do code in the text mode, and not the visual. Here is the code exactly as I have on the page: (just to make sure, I’ve copied the code into a text editor, and re-typed the single quotes.)
[connections show_empty_categories='false' image='logo' image_fallback='none' initial_results='false' show_alphaindex='true' repeat_alphaindex='false' force_home='true' exclude_category='1']
I’m still getting the uncategorized in the drop down list.
-
AuthorPosts
You cannot reply to this support topic. Please open your own support topic.
