2

I've found out how to search and display matrix rows, but the search results page will typically only show ALL rows.

How can I limit the results and show only the row where the item exists?

{exp:search:search_results}
{title}
{matrix_stuff}{matrix_title}{/matrix_stuff}
{/exp:search:search_results}

EDIT: There is a hack that works, but not a definite answer:

In mod.search.php add after line 1298( before $pagination):

// hack
// Load the XML Helper
$this->EE->load->helper('xml');

$keywords = $this->EE->functions->encode_ee_tags(xml_convert($query->row('keywords')));
// end hack

And after line 1411 before $channel->fetch_categories();

// hack add keywords
$this->EE->TMPL->tagdata = str_replace(LD.'keywords'.RD, $keywords, $this->EE->TMPL->tagdata);
// end hack

This makes it possible to use this:

{exp:search:search_results}
{title}
{matrix_stuff search:matrix_col_name="{keywords}"}}{matrix_title}{/matrix_stuff}
{/exp:search:search_results}

Not implemented in 2.7.0 :-(

2

Make the sure the matrix field and columns are searchable first. Then you could do something like what I have below, but you're limited to what matrix columns you can search.

{exp:search:search_results}
    {my_matrix_field search:matrix_col="{exp:search:keywords}"}
        {matrix_title}
    {/my_matrix_field}
{/exp:search:search_results}

Like Robson mentioned below, you can do either a "contains" matching (above) or an "exact" matching search by adding the = in front of the {exp:search:keywords}

| improve this answer | |
  • 1
    I can't edit your answer. You need to remove one "=". We need a “Contains” Matching, not a “Exact” Matching: 'search:matrix_col="{exp:search:key...' – Robson Sobral May 31 '13 at 12:44
  • Siebird, thanks very much, this seemed like the perfect answer, however, when used inside the {exp:search:search_results} tag, the {exp:search:keywords} is annoyingly outputted as the string that is used in the URL. – noregt May 31 '13 at 13:14
  • That's odd. What happens when you use the {exp:search:search_results} tag outside of the matrix ? – Siebird May 31 '13 at 14:07
  • 1
    Well Siebird it seems like this is a parse order issue. Outside matrix this only happens when using {exp:search:keyword} outside and inside the results tag pair. Removing the first makes it work However still not inside Matrix. Now it shows every row with "} at the end of the line. – noregt Jun 11 '13 at 8:41
  • 1
    Are you using {exp:search:keywords} twice and having issues? Please, try {exp:search:keywords random} – Robson Sobral Sep 4 '13 at 13:10
1

Ok found a simpler way to get this to work with an embed (have not tested with native EE search)

Source:

| improve this answer | |
  • Sounds good, but you'll need to get Low Search for this in order to make it work. Still, this is a better solution then hacking around in EE – noregt Sep 6 '13 at 14:53
0

Install Mo' Variables: http://devot-ee.com/add-ons/mo-variables

Change your template to this:

{exp:search:search_results}
    {my_matrix_field search:matrix_col="{post:keywords}"}
        {matrix_title}
    {/my_matrix_field}
{/exp:search:search_results}
| improve this answer | |
  • Thank Brian. I've tested it, but that didn't work I'm afraid. It displays all rows with "} at the end. So again a familiar parse order issue. Not sure if that's the case for everyone, because Ellislab made a hack in mod.search.php (xml conversion) – noregt Sep 2 '13 at 10:41
  • I've tested it without the hack from Elislab, but the same issue – noregt Sep 2 '13 at 10:48
0

Have you looked at Sift?

http://devot-ee.com/add-ons/sift

It should do what you need. Hope it helps.

| improve this answer | |
  • Well, i wasn't aware of that, I'll take a look! – noregt Sep 10 '13 at 7:18
  • Sift is specific for matrix search/filtering only. – Visual Sep 10 '13 at 12:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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