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 5 replies, 2 voices, and was last updated 7 years, 6 months ago by
Steven Zahm.
-
AuthorPosts
-
04/04/2016 at 4:31 pm #371650
Scott
ParticipantWe’re using the search function in cmap to parse both categories and notes. It appears that it will return [at least some] plural search results when singular search terms are entered, but not vice-versa — certainly not where notes entries are parsed.
How can we revise the code to allow both relevant singular AND plural search results to be returned regardless whether or not the original search case is singular or plural.
(ie search for “television” returns both “television” and “televisions” related entries; search for “city” returns both “city” or “cities” related entries.)
Please advise.
04/04/2016 at 7:39 pm #371653Steven Zahm
Keymaster@ NuMedia
You would have to hook into the cn_search_terms filter look for singulair or plural version of the strings and add them to the search terms array accordingly.
Hope that helps!
04/05/2016 at 10:04 am #371714Scott
ParticipantThis helps, but I’m having a difficult time parsing the code for the proper hook from the theme functions file. Could you provide an example?
04/06/2016 at 12:58 pm #371883Steven Zahm
Keymaster@ NuMedia
re: I’m having a difficult time parsing the code for the proper hook from the theme functions file.
I gave you the proper hook name,
cn_search_terms
and link to its location in the file. Here it is again:I suggest adding the this using the Code Snippets plugin. Never, never, plop code in the theme’s functions.php file regardless what all those old tutorials on the web say to do.
re: Could you provide an example?
Completely untested…
add_filter( 'cn_search_terms', 'NuMedia_Search_Filter' ); function NuMedia_Search_Filter( $terms ) { if ( in_array( 'city', $terms ) ) { $terms[] = 'cities'; } return $terms; }
05/11/2016 at 4:28 pm #376058Scott
ParticipantThis reply has been marked as private.05/12/2016 at 11:46 am #376158Steven Zahm
Keymaster@ NuMedia
Hmmm…
I just copied/pasted the code example I gave with zero changes into a Code Snippet so it would run on my dev site. I then added two new organizations, One name ‘City’ the other named ‘Cities’ when the code activate the search result was both entries. Without it active, only the ‘City’ entry returned as a search result. For good measure and picked just some random entry and added the `cities’ to the bio field and that too would return as a search result. So, the code snippet I gave does work.
I can custom code something for you but I would need a “dictionary” of singular/plural words that you would want to be searched when the opposite was supplied by a user when performing a search. I highly recommend keeping this “dictionary” small and relevant.
I can supply you with a quote, please contact me using the Contact link at the very bottom of the page.
-
AuthorPosts
You cannot reply to this support topic. Please open your own support topic.