Jump to content

How to search for fields in Repeater Matrix


hellerdruck
 Share

Recommended Posts

Hi all

I have a text search based upon Ryans search template. Unfortunately, I can't make it work with Repeater Matrix fields inside repeaters.

I have a repeater field called "content_sections" and inside, there's a repeater matrix field called "items". As I understand it, the selector for a textfield inside the repeater matrix should be: content_sections.items.textfield

But this does not deliver any results at all. 

Any ideas anyone?

Thanks

Roli

Link to comment
Share on other sites

In your selector the Repater Matrix Type is missing. Your "items" repeater matrix field needs to have some named "types" setup in the field configuration screen. The textfield is inside that type.

If repeater matrix field "items" with type "image_text" has a field "textfield", your selector would look like: content_sections.items.type=image_text

To get all pages that have items of type image_text  you can use. 

$pagesWithType = $pages->find("content_sections.items.type=image_text");

To get all the texts you need to loop through those pages and get your textfield value

foreach($pagesWithType as $p) {
    $term = $p->get('textfield');
}

Or you can get an array of all terms like this

$terms = $pagesWithType->explode('textfield');

Seehttps://processwire.com/api/ref/wire-array/explode/

EDIT: removed initial selector added code with loop etc

  • 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

×
×
  • Create New...