Forum
Using content from perch_content_custom on a page by page basis
Hello!
I wonder if you could help me - it's probably me not being very good, but hopefully someone has an answer.
I am getting content from multiple regions on a page, i.e.
perch_content_custom(
array(
'Artist Name',
'Artist Images'
),
array(
'page'=>'/artists/*',
'template' => '_artist_list.html'
)
);
But when the data comes out, it loops through the data displaying the data for Artist Name in _artist_list.html, then Artist Images in _artist_list.html and so on.
How can I group the content returned to a template per page basis, so for the first page it would output both regions from page1.php into _article_list.html, then both regions from page 2 into _artist_page.html
I guess it might be by I need to use the callback (each) function - to group page items together and then return a new array item with the data from each page?
Hope that's clear enough - if not, I'll explain further anyway I can.
I've managed using what I think is a bit hacky, but given fields will always exist it should be OK;
Not sure if that was the best solution though - an example of how I could merge data in the each function would be great ;)
Thanks,
Matt
Yes, you could merge data using an
each
callback, or if you're using Runway just create a relationship.But what you're doing will also work. It's always a bit dicy selecting from multiple regions - I added that feature while muttering under my breath that I shouldn't ;)
Thanks Drew,
I thought that it was a bit dicy, as you say. I think I might refacter it to loop through the pages and create the html and data in the page itself, using navigation and then just getting the data from the multiple regions as I need it.
Cheers! Keep up the good work!