Jon Posted July 27, 2016 Share Posted July 27, 2016 Hello All, I am just wondering what is the best way to get a specific row of a repeater. I have a list of courses stored in a repeater. On my parent page i will list all the courses/dates and when. What I planned on doing was getting the ID of the row in a GET and then showing the content of the repeater row on the booking page. Can this be done without using a foreach? Cheers Jon Link to comment Share on other sites More sharing options...
blynx Posted July 27, 2016 Share Posted July 27, 2016 Hej, maybe $page->repeater->eq()? see: https://processwire.com/api/ref/wire-array/ cheers! Steffen 1 Link to comment Share on other sites More sharing options...
Robin S Posted July 27, 2016 Share Posted July 27, 2016 If I understand right, you will be outputting all the repeaters on the parent page and each of these will include a link to the booking page. Because a repeater item is a page you can use the page ID to identify it. So on your parent page... foreach($page->my_repeater as $repeater_item) { $link = "/booking/?id={$repeater_item->id}"; // output the markup for your repeater item including the link } And on the booking page... $id = $sanitizer->int($input->get('id')); $repeater_item = $pages($id); if($repeater_item->id) { // output the markup for your repeater item } You could use a URL segment instead of a GET variable if you prefer. 1 Link to comment Share on other sites More sharing options...
Jon Posted July 27, 2016 Author Share Posted July 27, 2016 Hey guys thanks for the input. I went with the option from Robin just reading up on URL segments now as that looks like a even better option. Cheers Jon 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