Frank Vèssia Posted November 27, 2013 Share Posted November 27, 2013 Hello guys, assuming I have a lot (more than 100) repeater items and I want to edit a specific one, there is a fast way (with a selector) to get the specific item i want, edit it and save it, without loop through all items to find it? Link to comment Share on other sites More sharing options...
ryan Posted November 30, 2013 Share Posted November 30, 2013 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. 2 Link to comment Share on other sites More sharing options...
jensendd Posted December 4, 2013 Share Posted December 4, 2013 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 More sharing options...
ryan Posted December 11, 2013 Share Posted December 11, 2013 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 More sharing options...
lpa Posted February 19, 2014 Share Posted February 19, 2014 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 More sharing options...
apeisa Posted February 19, 2014 Share Posted February 19, 2014 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. 2 Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now