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.

custom search

November 26, 2008 8:09am

Subscribe [4]
  • #1 / Nov 26, 2008 8:09am

    yehosef

    17 posts

    Is it possible to search for values in a specific field - for example, I have a custom field type called “job_type” which can contain the values “permanent, parttime,contract,freelance” and I want to be able to search and filter based on that.  Eg, all the posts with php in the title/body and freelance in the “job_type” field.

    [update]
    A workaround I just found while posting this is to label all my form fields “keywords[]”

    and change line 478 in core.regex.php from

    $str = strip_tags($str);
    if (is_array($str)) {
      $str = implode(' ',$str);
    }
    $str = strip_tags($str);

    This will quickly turn my search for “css” in “freelance” job_types to “css freelance” which will match both the fields.  But I’m not sure if I’m going to miss some edge cases - is there an official way to do this?

    Moved to HowTo by Moderator

  • #2 / Nov 26, 2008 9:54am

    Sue Crocker

    26054 posts

    Hi, Yehosef.

    I found the following EEWiki entry: Order Search by Custom Field

    Since this is more of a How Do I question, I’m going to move this thread to HowTo.

  • #3 / Nov 26, 2008 10:27am

    yehosef

    17 posts

    Hi thanks for the reply,

    That post seems to be talking about how to order the result based on the field, which is also good to know, but I’m referring to filtering the results based on the field. So in my example above, not that i’ll have all the freelance and full-time jobs ordered/grouped together, but that I will only see matches for the value I search for.

  • #4 / Nov 26, 2008 10:51am

    Boyink!

    5011 posts

    Have you investigated use of the search parameter for the weblog:entries tag?

    Using it with some custom URL segments might be a way to get what you want.

  • #5 / Nov 26, 2008 11:39am

    yehosef

    17 posts

    Thanks for the idea - so maybe the solution would look like this:

    I would set up the form with target being some other page with php enabled and parsing on input - I’ll then use php to get the POST variables (or GET depending) from the form and I’ll manually build a weblog tag with the search parameters passed in. 

    I’ll basically bypass the search function all together.

    [edited] - I’ll try it.

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

ExpressionEngine News!

#eecms, #events, #releases