Forum
Mixed listing page with content custom
Hi Drew/Rachel,
I have a Perch site where I am listing projects with a certain category as show below:
<?php
perch_content_custom('Projects', array(
'page' => '/project.php',
'template' => 'project_listing_cgi.html',
'category' => array('project-tag/cgi'),
));
?>
My client wants to add 'Quotes' to the site that are show as part of the same listing above. The quotes are not related to a project but they want to disperse them within the project listings.
Is there any way of doing this in Perch?
This is the code for project.php
<?php
perch_content_create('Projects', array(
'template' => 'project_detail.html',
'multiple' => true,
'edit-mode' => 'listdetail',
));
perch_content_custom('Projects', array(
'template' => 'project_detail.html',
'filter' => 'slug',
'match' => 'eq',
'value' => perch_get('s'),
'count' => 1,
));
?>
To what level do you need to control how they're interspersed? Is it something like a quote after every 3 items? Or does it need to be manual?
Hi Drew,
Ideally it would be manual.
I can't think of a good way to do that.
OK, thanks Drew.
Would it change things if we were to intersperse every 5th item or so?
Yes, you'd fetch the regions using the
split-items
option and then loop through and intersperse them.Hi Drew,
Client is happy to intersperse every 5th item but I am struggling to find any documentation on the
split-items
option.I assume I need to use something like this:
But that is where I get lost - how would I: a) Pull in content from two pages b) Use different templates to display Projects and Quotes c) Intersperse them where listed
Thanks in advance, Andy
split-items
uses the template as normal, but returns an array of the individual HTML blocks. This enables you to loop through them and manipulate or output as required.Anyway. Something like:
Thanks Drew,
I'll give this a go :)