dab Posted July 25, 2017 Posted July 25, 2017 I'm using the "wire ('pages')->get" hook for an event calendar. The wire hook below is "hard coded" & works fine $events = wire('pages')->get("/courses/skills/")->date_repeater; But I want to get the repeater for the current page (being viewed) I've tried lots of ways of replacing the "->get" to get the repeater from the current page, but no luck. I've tried $currentpage = $page>path; & replacing the get("/courses/-skills/") with $currentpage but no joy.... Any hints would be a huge help.
louisstephens Posted July 25, 2017 Posted July 25, 2017 Couldn't you do something like: <?php foreach ($page->date_repeater as $date) { #code... } ?> This also has some examples of repeaters being used:
dab Posted July 25, 2017 Author Posted July 25, 2017 @louisstephens Thanks.... It's got to be called via a hook, rather than a regular call from a page function getEvents() { $events = wire('pages')->get("/courses/hill-skills/")->course_start_date_repeater; foreach ($events as $event) { echo "'$event->course_start_date' : '<span>BOOK BELOW!</span>',"; echo "'$event->course_finish_date' : '<span>PICK THE START DATE!</span>',"; } }
louisstephens Posted July 25, 2017 Posted July 25, 2017 Just now, dab said: @louisstephens Thanks.... It's got to be called via a hook, rather than a regular call from a page function getEvents() { $events = wire('pages')->get("/courses/hill-skills/")->course_start_date_repeater; foreach ($events as $event) { echo "'$event->course_start_date' : '<span>BOOK BELOW!</span>',"; echo "'$event->course_finish_date' : '<span>PICK THE START DATE!</span>',"; } } My apologies on that. I should have picked up on the function reference.
dab Posted July 25, 2017 Author Posted July 25, 2017 Got it! So simple really $events = wire('page')->course_start_date_repeater;
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