Forum
Retrieve page title when using perch_content_custom
Hi. I'm using perch_content_custom
to display truncated content from a set of pages elsewhere on the site. Is there a way, within that loop, to retrieve the page title for each page?
Here's the code that produces the loop:
<?php
perch_content_custom('Service', array(
'page'=>'/services/**/*',
'template'=>'service_abstract.html'
));
?>
This works well, looping through each /services/ page and displaying the content from each 'Service' region. But I'd also like to display the page title. Is there a way to do this? Thanks in advance :)
I don't know if I'm over-complicating this or not, but:
I think you'll have to use the
each
optionWithin that function (the "processing" bit), I think you would have to get the
$item['pageID']
and then pass that into:(So, you're getting the pageID from each loop, passing it into the perch_page_attribute function and then adding a new field to each item).
You can call that new field in your template by using
<perch:content id="page_title" />
Untested. I think it's right though.
Thanks!
$item['pageID']
is missing an underscore - it should be$item['_pageID']
- but other than that it works perfectly!Excellent!