0

Is there an easy way to search within a Matrix field for a particular value and if it matches to display the associated entry? Similar to how the "search:" parameter allows you to constrain Channel Entries output based on content within your fields. I want to do something like this:

{exp:channel:entries
    channel="shows"
    search:show_uid="={segment_2}"
    limit="1"
    show_expired="yes"
    dynamic="off"
}

"show_uid" is the name of my Matrix field and the value I'm trying to match is in column 2.

2 Answers 2

0

If you mark a Matrix column as Searchable, then its content will be stored as keywords on the parent entry, and you will be able to search for it via {exp:channel:entries}’ search:field_name= param.

Couple caveats, though:

  • Remember that we’re just talking about keywords here. You can’t search for specific cell values, since those values are just getting dumped along with all other cells’ values for all of your searchable columns. So don’t prefix your search:field_name= param value with =, e.g. search:field_name="=somevalue".

  • If you set a column to Searchable after you’ve already saved some entries, you will need to re-save those entries for the setting to take effect.

2
  • What is being set in the database when the entry is re-saved? Jul 23, 2015 at 17:09
  • The relevant change, as far as this Searchable setting is concerned, is that the columns’ search keywords will be included in the data Matrix stores in the exp_channel_entries table. That’s the table that the search:field_name= parameters will query against. Jul 24, 2015 at 22:00
0

https://ellislab.com/expressionengine/user-guide/add-ons/channel/channel_entries.html#search-field-name

You can search in matrix fields, no problem! Just make sure that the matrix column is set to searchable. Check this answer for some pictures:

Search in Matrix Fields

{exp:channel:entries
    channel="shows"
    search:show_uid="={segment_2}"
    limit="1"
    show_expired="yes"
    dynamic="off"
}

    If you're seeing this, it's because we have a search result within the matrix field you wanted to search in!

{/exp:channel:entries}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.