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.

Filter entries by multi select field

February 01, 2012 9:36am

Subscribe [2]
  • #1 / Feb 01, 2012 9:36am

    gents agency

    16 posts

    Hi,

    I’ve read in the online documentation that the search:fieldname=“value” functionality for the channel module doesn’t support multi select fields.

    I’ve been looking for plugins and alternatives since, but to no avail.
    Has anyone been able to do this?

    Thanks!
    Diederik.

  • #2 / Feb 01, 2012 10:49am

    mark186282

    290 posts

    the issue (in my experience) is that it won’t return unique values… because you can’t do an search:fieldname=”=exactmatch”... and without the “=exactmatch” you may get returned results that you don’t want

    let’s run through an example:

    fieldname = artist_medium

    options:

    ink
    pastel
    oil
    pencil
    chalk
    soil (i put this one in to support my example… although there may be some soil artists out there…)


    I create a template to pull articles about different media (mediums?)

    mysite.com/mediumtalk/article/

    and in this article page, I use {segment_3} to drive the content…

    {exp:channel:entries channel='medium_articles' search:artist_medium='{segment_3}'}

    So I load up my URL:

    mysite.com/mediumtalk/article/oil


    This *should be* a list of all my oil articles… but those blasted soil people keep crashing my party:

    BECAUSE the field_id_123 field is storing the checkbox content as pipe delims:

    Ink/Oil/Chalk article is stored like this:
    “ink|oil|chalk”

    Pencil/Soil is stored like this:
    “pencil|soil”

    BOTH return positive for

    search:artist_medium=‘oil’

    AND NEITHER return positive for

    search:artist_medium=’=oil’

    {exp:channel:entries channel='medium_articles' search:artist_medium='={segment_3}'}


    .... SO - you can do a search on the fields, but you can run into problems with getting the exact results you are looking for…


    and, no, I have no idea about a plugin that will solve it - although there may be one out there.

     

  • #3 / Feb 02, 2012 3:44pm

    Dan Decker

    7338 posts

    Hi Diederik,

    I’m sorry the search parameter doesn’t support the functionality you are looking for. Feel free to submit a Feature Request for that! I couldn’t find any add-ons that would fit this need either.

    Cheers!

  • #4 / Feb 03, 2012 3:43am

    gents agency

    16 posts

    Hi all,

    I’ve done it the old fashion way, using php. I’ve filtered all the entry_ids of the entries, put them into a string and placed them in the entry_id parameter of the channel entries tag. That way I can still make use of all the advantages of the channel module. And it works.

    I’m not a big fan using php in EE. But I’ve used the db and uri class, so I think it’s pretty safe.

    I think, multi select fields aren’t the only type of field that could be searched trough. It might be helpful to add the functionality to all types of fields. Including third party fieldtypes. And provide the third party add-on developers with the possibility to make their fieldtypes searchable within the channel entries tag.

    Thanks for the help!

  • #5 / Feb 06, 2012 4:35pm

    Dan Decker

    7338 posts

    Hi gents agency,

    I’m glad you were able to come to a solution that works well for you. Thanks for sharing the process with the Community!

    If you need assistance in the future, just let us know in a new thread!

    Cheers!

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

ExpressionEngine News!

#eecms, #events, #releases