Jump to content

[Solved] Search text into field included in repeater


abmcr
 Share

Recommended Posts

I have a field named"testo" (textarea) included in various templates (home, page, post) ; in one of these the template (post) the field "testo" is an input of a repeater field named "pagina_blocco".
If a search a word this selector

//$q is the search word
$matches = $pages->find("testo~=$q");

the selector get the text only if the "testo" field is not included in the repeater, ie only in the home and page template but not if the word is in the field when this is included into the repeater. I have try with a simple SQL directly on db

SELECT * FROM `field_testo` WHERE `data` LIKE '%ente%'

and this query find 2 rows: but only the row corresponding to a page
5a1aee9b0fd9a_Schermata2017-11-26alle17_31_41.png.63f285dc930acb71bfb9a19319e9c2f4.png

The 2 pages founded by query

5a1aef3a61572_Schermata2017-11-26alle17_42_07.png.ac214acc612a9c05f92ebfb94103225a.png

And the corresponding templates: the id 61 is a repeater

5a1aef3b73436_Schermata2017-11-26alle17_43_14.png.1c40da765cd00946f7c420cd916941ff.png
But in the search page only the pages_id=1 is showed by the selector.

5a1aee9c6d5eb_Schermata2017-11-26alle17_32_12.png.089be8f35f70d823f7ac58d6f0be37b3.png

If i edit the selector in 

$matches = $pages->find("testo~=$q,template=home|repeater_pagina_blocco14")

the search find also the second row , but in the matches result the ID of page in witch the repeater are included is not present.....

How it is possible to search into a field included in a repeater? Obvious it is possible with a series of query from the db.. but this is not PW style ;)

Thank you

 

 

 

Link to comment
Share on other sites

5 hours ago, abmcr said:

//$q is the search word
$matches = $pages->find("testo~=$q");

the selector get the text only if the "testo" field is not included in the repeater, ie only in the home and page template but not if the word is in the field when this is included into the repeater.

Try:

$matches = $pages->find("testo|pagina_blocco.testo~=$q");

 

Link to comment
Share on other sites

Welcome to the forums @adiemus

The description field is named "description" and you can include it as a subfield of an images field in your selector. So for a repeater field named "repeater" containing an images field named "images" your selector would be something like:

$matches = $pages->find("repeater.images.description~=foo");

 

  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...