Forum
Extended Navigation when creating Perch pages
Hi,
I've got a "Services" page which currently contains 4 services. These 4 services each have a page, created in Perch. On this main services page I want to display the services as a list, with a link to click through. Using perch_pages_navigation, the data I can get from each page seems limited to the url, title and description fields etc.
Is there any way to access regions used on the individual services page? So each service page has a synopsis (Created using a region called Individual Service Synopsis) and an image (created using a region called Individual Service Images). Can I pull this synopsis and image in anyhow to the main "Services" page?
If not, am I better off going down the List Detail route for this?
Thank you.
You should be able to achieve this with
perch_content_custom()
: Using content from different pagesHi Hussein, thanks for that, that has got me somewhere! But it's outputting all at once. I've iterated over them using
but am struggling to access this using a template as I can't reference the template in the each loop. I've gone back to basics, my code is below, so it's grabbing the content from the region:
Is there a way to spit the content from the region (Individual Service Synopsis), into the template using <perch:content> tags?
Thanks.
Just to help with what you want to do, when you say "outputting all at once", is that not what you wanted? You want a one page list of data that lives on 4 other pages?
Or do you mean that all the content from each page is showing, as opposed to just the image and the synopsis?
Hi Duncan, basically I have 4 pages (created in Perch) that are each a service, I.e dog walking, dog sitting, dog feeding etc
Each page has a region called 'Individual Service Synopsis'. On the main services page (effectively the listing page) I want to display the synopsis for each service and then a link to that page underneath. Using perch_content_custom I can access the region but it spits all 4 synopsis' out at once.
If I use the "each" function I can loop through and show what I want to show (synopsis and link) but it involves echoing a lot of HTML in the each function. I'd rather get the HTML in a template and call the template in the each loop each time. It doesn't appear this is possible however?
Thanks.
You need to get the navigation using
skip-template
and then loop through those pages callingperch_content_custom()
with the currentpage
option for each.Thanks Drew, that has got me what I need. I think what I was after isn't possible anyway. I was just hoping to keep the PHP a bit clean and let a template do the work. This is my code (before adding HTML to the foreach loop) in case it helps anyone else: