Jump to content

Search specific repeater item and edit


Frank Vèssia
 Share

Recommended Posts

It sounds like you are talking about from the API side. You can work with repeaters just like any other pages, but you just have to know where to find them. Your repeater items are going to be using a template with the name of your repeater field pepended by "repeater_". So if you've got a repeater field called "slideshow", then pages within that repeater are going to be using the "repeater_slideshow" template. As a result, you can query them like this:

$pages->find("template=repeater_slideshow, ..."); 

Repeaters are kept in the admin structure, so if your code needs to do it's thing on the front-end of your site, then you'll also want an "include=all". Note that unpublished+hidden repeaters are considered unpopulated "ready" pages, so you can safely skip over them. 

  • Like 2
Link to comment
Share on other sites

Ryan,

Are you saying that every single repeater has a default template assigned to it by the system, identifiable by the repeater's name, prepended by "repeater_" ?

My problem is getting a list of a repeater's pages to select from in the admin but on another page.

In short, my tree's like this:

Home

    Projects

        Project-1

            Repeater

                Repeater-item-1

                Repeater-item-2

                Repeater-item-3

        Project-2

            Repeater

                Repeater-item-1

        Project-3

            Repeater

                Repeater-item-1

                Repeater-item-2

 
 

On Home, I'd like to be able to select multiple repeater items, but I can't find the right selector for the job – your answer in this thread gave me hope, but no luck when testing so far.

Hope you can help. It would round off my very first PW project – absolutely loving working with the API and it's simplicity (as a MODX convert). I'm sold :)

Thanks!

Link to comment
Share on other sites

Are you saying that every single repeater has a default template assigned to it by the system, identifiable by the repeater's name, prepended by "repeater_" ?

Yes, every single repeater field has an associated template. 

On Home, I'd like to be able to select multiple repeater items, but I can't find the right selector for the job – your answer in this thread gave me hope, but no luck when testing so far.

Repeaters aren't designed to be used in this way (selecting repeaters from one page on another page), this is really more a use case for regular pages sans repeaters. Though I'm guessing that technically  you could still do it if you needed to by creating a Page reference field that selects your repeater template with a custom selector like this defined in the field settings "template=repeater_something, check_access=0, sort=title", replacing the "sort=title" with whatever would be the appropriate field to sort on. 

Link to comment
Share on other sites

  • 2 months later...

I have a template called concert, which has a repeater called event, which has a field called concerthouse, which is a page reference to a page with a template that has fields: title, address and city. If I want to search for the concerts that are held in  a concerthouse whose title I would like to search, how would I make the find on my search.php template?

Simplified find with only the concerthouse.title -field:

I have tried $pages->find("template=concert|repeater_event,event.concerthouse.title~=$q"), but this doesn't work. 

And I don't want to get the repeaters as the result pages, but the concerts. And not the concerthouse-pages but the concerts.

Link to comment
Share on other sites

Find concerthouses first:

$concerthouses = $pages->find("template=concerthouse, title~=$q");

Then find events that are held in any of those:

$concerts = $pages->find("template=concert, event.concerthouse=$concerthouses");

Ah, sorry, missed the repeater part... updated above.

  • Like 2
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...