ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Make a URL perform an advanced search?

August 16, 2011 4:45pm

Subscribe [2]
  • #1 / Aug 16, 2011 4:45pm

    philanthropyRT

    9 posts

    Hey gang,

    I’m wanting to make a URL perform an advanced search.
    So you’d click on a link, which fires a search, where a custom field in a specific channel is searched.

    LIke this,

    {exp:search:advanced_form result_page="search/results" search:article_type="{article_type}" }

    .... but in a URL.

    Can this be done?

  • #2 / Aug 17, 2011 2:07am

    John Henry Donovan

    12339 posts

    philanthropyRT,

    Solspace’s SuperSearch add-on has the functionality to handle custom URL search

    Out of the box you could use the Channel Entries tag parameter search://field_name=
    Only fields of the type “Text Input”, “Textarea”, and “Drop-down Lists” are searched with this parameter.

    So for example you could generate a URL like http://www.mydomain.com/news/search/search_keyword

    Then inside the search template you could have

    {exp:channel:entries channel="news" dynamic="no" search:body="{segment_3}"}

    That is a rough idea but hopefully you get it’s context.

  • #3 / Aug 17, 2011 2:25pm

    philanthropyRT

    9 posts

    Hey John, thanks for the response.

    Out of the box I may not be able to get to where I’m searching (pun intended). Your example is pretty right on spot to what I’ve been attempting to do as another path.
    My problem comes up that the keyword field I’m searching for contains spaces. When trying to call the variable through {segment_x}, spaces aren’t supported in the URI.

    To try to work around this, I wrote a little plugin that will replace Spaces ” ” with Underscore “_”. So James F Barringer -> James_F_Barringer. The roadblock came in when trying to apply another custom plugin inside the {exp:channel:entries} to strip the underscore from segment 3. It won’t work (sad face).

    See where my custom plugin “strip underscores” won’t work:

    {exp:channel:entries channel="articles"  dynamic="no"  search:author_name="{exp:sus}{segment_3}{/exp:sus}"}

    Unless I get even more clever without over complication I may just go drop some more change on SolSpace 😉

  • #4 / Aug 19, 2011 3:44am

    John Henry Donovan

    12339 posts

    philanthropyRT,

    You could use an embed and pass the string converted by the plugin

    {embed="_includes/search-listing" segString="{exp:sus}{segment_3}{/exp:sus}"}

    Then in your embed

    {exp:channel:entries channel="articles"  dynamic="no"  search:author_name="{embed:segString}"}

    I am going to move this thread to Community Help as it is more appropriate there and allows us to keep the thread open for you.

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases