Forum
Is it possible to use perch_content_custom() in content templates?
In this project's design we have a page called Our Packages and a page called Our Results.
Our Results has a region called Results which is a repeating region.
On Our Packages, we have a region called Packages which uses a custom content template to enable the user to enter the package content. In the design there is a need to pull into this view a particular item from the Results region on the Our Results page, so I was hoping something this would work:
<h1><perch:content id="title" type="text" label="Title" required="true" title="true" /></h1>
<perch:content id="text" type="textarea" label="Text" required="true" />
<h2>Recent Results</h2>
<?php perch_content_custom('Results', array(
'page' => '/our-results.php',
'template' => 'result.html',
'count' => 1,
'sort' => 'date',
'sort-order' => 'DESC',
'filter' => 'package',
'match' => 'eq',
'value' => '<perch:content id="title" type="text" label="Title" urlify="true" />'
)); ?>
This would pull through the latest Result item that meets the filter. However that doesn't get parsed so I'm guessing it's not possible to use perch_content_custom() from within a content template?
Thanks
Templates are HTML, you can't use PHP in them.
Doh! Sorry what a daft question to ask! Can't believe I didn't see that.
Use
perch_content_custom()
in the page and then usePerchSystem::set_var()
to pass the result into the template.