6

I'm using a Grid field (ee2.7) for a FAQ channel. The Grid has 2 column and both are Searchable. How can I display in a Searchresult the row where the term is found. Right now it display the first row of mijn Grid field and not the one where the term is found.

Is it possible?

Francois

3
  • I'm also looking for an answer to this question. AFAICT it's not something that can be done natively; if that's the case then it's definitely something that EllisLabs should look at, because it makes Grid a poor relation to other fields when it comes to search results.
    – RickL
    Feb 7 '15 at 17:16
  • possible duplicate of How to get results from a grid field in low search
    – Blatant
    May 12 '15 at 16:34
  • Hey Francois, did you get this sorted or are you having issues still?
    – Blatant
    May 22 '15 at 9:11
1

You certainly can. take a look at the search:column_name parameter of the grid tags.

The idea is in your results loop, call the grid tags with the search parameters from the origional search, something like this (untested) :

{exp:search:search_results}

    {my_grid_field search:column1="{exp:search:keywords}" search:column2="{exp:search:keywords}"}

         <h2>{my_grid_field:column1}</h2>
         <p>
             {my_grid_field:column2}
             <img src="{my_grid_field:column3}" alt="{my_grid_field:column1}" style="float:left;" />
         </p>

    {/my_grid_field}

    <hr />

{/exp:search:search_results}

The idea is we're using the good old grid tag pair, and redoing the search by passing the search string back into the grid field. Simple really.

You can also use one of the myriad of string replacement modules to find and highlight your search terms in the grid columns...

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.