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.6.7, cMap, custom field, drop down, template
- This topic has 9 replies, 2 voices, and was last updated 9 years ago by
Steven Zahm.
-
AuthorPosts
-
07/26/2017 at 2:42 am #430384
Adam Leone
ParticipantI want to add a second dropdown to the filter for gender. What template would I do this in?
07/27/2017 at 4:19 pm #430531Steven Zahm
Keymaster@ Adam
How are you setting the gender?
07/28/2017 at 12:15 pm #430623Adam Leone
ParticipantIts a custom field. I just need to know what file I would add the dropdown code to.
Regards,
David
07/28/2017 at 2:17 pm #430630Steven Zahm
Keymaster@ Adam
You do not really add it to a template file, sort of… so it is somewhat difficult to explain…
I see you’ve purchased cMap sooo… you could add the code to the
cmap.phpfile. I recommend using the Code Snippets plugin to add the drop down. This way adding the drop down is update safe.You would hook into the
cn_action_list_before-cmapaction to render the drop down. Example:add_action( 'cn_action_list_before-cmap', 'cn_add_gender_dropdown', 5 ); function cn_add_gender_dropdown() { //echo you code for the drop drown }To make it functional you will also need to hook into the
cn_list_retrieve_atts-cmapfilter like so:add_filter( 'cn_list_retrieve_atts-cmap', 'cn_gender_meta_query' ); function cn_gender_meta_query( $atts ) { // NOTE: only set the meta query if the user has selected a gender $atts['meta_query'] = array( 'meta_key'=> '{custom-field-id}', 'meta_value' => '{gender}'); return $atts; }08/03/2017 at 12:03 pm #431238Adam Leone
ParticipantI have since discovered its not a custom field but the ‘Suffix’ field. What would be the code required for that?
08/03/2017 at 1:11 pm #431242Steven Zahm
Keymaster@ Adam
Well, the code for the drop down would be the same, the issue is there is no method available which can be easily implemented to search the suffix field.
08/08/2017 at 2:28 am #431668Adam Leone
ParticipantI have used the following code to get gender to be searchable:
if (isset ($_GET['gender']) && $_GET['gender']) { $where[] = ' AND honorific_suffix = "' . htmlentities($_GET['gender'], ENT_QUOTES) . '"'; }However there are 2 issues:
- The gender box resets when the search is performed
- The text does not say that the user searched the gender as it does for category:
“You are searching within category(ies): Accident and emergency”
How do I get the text to also say “”You are searching within gender: Male” for example?
Regards,
David
08/08/2017 at 10:19 am #431706Steven Zahm
Keymaster@ Adam
RE: The gender box resets when the search is performed
In the code you used to create the dropdown (I assume that is what you mean by gender box) you need to check for gender query string and set the option selected tag in the drop down.
RE: The text does not say that the user searched the gender as it does for category:
You can hook into the
cn_search_results_messagesfilter which passes an array of search messages. YOu can add you gender message to the array if the user is searching by one.Hope this helps!
08/11/2017 at 3:53 am #431985Adam Leone
ParticipantHi Steven,
Where can I read about that hook (cn_search_results_messages)
Thanks,
David
08/11/2017 at 10:17 am #432025Steven Zahm
Keymaster@ Adam
There’s nothing available to read. You would hook into like the other filters:
add_filter( 'cn_search_results_messages', 'cn_gender_search_results_messages' ); function cn_gender_search_results_messages( $messages ) { $messages['cn-gender'] => 'The results are being filtered by gender.'; return $messages; }You would of course add the logic to deal with changing the message string based on if gender is being search and by which.
-
AuthorPosts
You cannot reply to this support topic. Please open your own support topic.
