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.
Tagged: 8.1.5, shortcode, slim plus, str_select, str_select_all
- This topic has 12 replies, 2 voices, and was last updated 8 years, 6 months ago by
Steven Zahm.
-
AuthorPosts
-
11/07/2014 at 9:55 pm #309443
Steve Yancharas
GuestHey Steven, can you point me in the right direction on how to change the Select Category drop-down on the main directory listing page to a Select State that will search by state?
Thanks,
Steve11/08/2014 at 9:41 am #309450Steven Zahm
Keymaster@ Steve
Sure, like this:
[connections str_select='Select State' str_select_all='Show All States']
Here’s a link to a FAQ that explains the str_***** shortcode options:
http://connections-pro.com/faqs/how-do-i-use-the-str_-shortcode-options/Here’s the page with all the Slim Plus compatible shortcodes:
http://connections-pro.com/documentation/template-doc/slim-plus-shortcode-options/Hope that helps!
11/11/2014 at 10:20 am #309641Steven Zahm
Keymaster@ Steve
Did you add the states as categories? The shortcode I gave only changes the strings, it does change the functionality.
11/11/2014 at 2:32 pm #309673Steve Yancharas
GuestOh no, we have 4000 records already with states assigned as states and was hoping to populate the drop-down with the states from the states field. Is that possible?
11/11/2014 at 9:29 pm #309692Steven Zahm
Keymaster@ Steve
Maybe this will work for you.
Install the Code Snippets plugin.
Add a new snippet with the following code:
function cn_state_select() { global $wpdb; $sql = 'SELECT state FROM ' . CN_ENTRY_ADDRESS_TABLE . ' GROUP BY state'; $result = $wpdb->get_col( $sql ); $keys = array_map( 'urlencode', $result ); $values = array_map( 'esc_attr', $result ); $states = array_combine( $keys, $values ); cnHTML::select( array( 'id' => 'region', 'name' => 'cn-region', 'options' => $states, 'enhanced' => TRUE, 'default' => array( 'Select a State' ) ) ); } add_action( 'cn_action_list_before-slim-plus', 'cn_state_select', 98 ); function cn_add_submit_button( $atts, $results ) { cnTemplatePart::submit( array( 'return' => FALSE ) ); } add_action( 'cn_action_list_before-slim-plus', 'cn_add_submit_button', 99, 2 ); function cn_disable_category_select( $atts ) { $atts['enable_category_select'] = FALSE; return $atts; } add_filter( 'cn_list_atts-slim-plus', 'cn_disable_category_select', 9 );
Save and activate the snippet.
-
This reply was modified 8 years, 7 months ago by
Steven Zahm. Reason: Fix link for Code Snippets
11/12/2014 at 2:32 am #309694Steve Yancharas
GuestWell thank you! I tried to click on the Code Snippets link but it looks like it goes back to this page, where do I find that plugin please?
11/12/2014 at 8:25 am #309729Steven Zahm
Keymaster@ Steve
Sorry about that. I fixed the link for Code Snippets.
11/12/2014 at 3:51 pm #309756Steve Yancharas
GuestThank you! Looks like it almost works, the dropdown says … and the states are there but doesn’t appear to sort by state when you hit submit. Can you take a look please?
11/12/2014 at 7:43 pm #309763Steven Zahm
Keymaster@ Steve
Oh, I see. It works for me because I’m working with my dev version of Connections which fixed two minor bugs with the the code that renders the drop down. Try this instead:
function cn_state_select() { global $wpdb; $sql = 'SELECT state FROM ' . CN_ENTRY_ADDRESS_TABLE . ' GROUP BY state'; $result = $wpdb->get_col( $sql ); $keys = array_map( 'urlencode', $result ); $values = array_map( 'esc_attr', $result ); $states = array_combine( $keys, $values ); cnHTML::select( array( 'id' => 'cn-region', 'name' => 'cn-region', 'options' => $states, 'enhanced' => TRUE, 'default' => array( 'Select a State' ) ) ); } add_action( 'cn_action_list_before-slim-plus', 'cn_state_select', 98 ); function cn_add_submit_button( $atts, $results ) { cnTemplatePart::submit( array( 'return' => FALSE ) ); } add_action( 'cn_action_list_before-slim-plus', 'cn_add_submit_button', 99, 2 ); function cn_disable_category_select( $atts ) { $atts['enable_category_select'] = FALSE; return $atts; } add_filter( 'cn_list_atts-slim-plus', 'cn_disable_category_select', 9 );
That minor tweak that should work in both versions. Let me know.
11/12/2014 at 10:26 pm #309772Steve Yancharas
GuestNice! It works but the dropdown says … instead of Select a State and there’s a 99 in the list for some reason.
-
This reply was modified 8 years, 7 months ago by
-
AuthorPosts
You cannot reply to this support topic. Please open your own support topic.