Forum
Filter Perch Collection with perch_page_attribute
Hi
I'd like to show a subset of the items in a collection on various pages in our site.
Id like to pass the value of page attribute to the perch collection, however this doesn't seem to work. Is there another way I can achieve this?
Here is the code that I'm using in the Master Page Template
<?php
include($_SERVER['DOCUMENT_ROOT'].'/includes/page_header.php');
$TourFilter = perch_page_attribute('filter', true);
perch_content('Page Body');
perch_collection('Tours',array(
'template' => 'tours_page_destination.html',
'filter'=>'destination',
'match'=>'eq',
'value'=> $TourFilter,
'sort' => 'destinationsort_australia',
'sort-order' => 'ASC',
'count' => 99
));
?>
<?php
include($_SERVER['DOCUMENT_ROOT'].'/includes/page_footer.php');
?>
At the moment, the perch_page_attribute is outputted to the page only. I've referred to https://docs.grabaperch.com/functions/page-attributes/perch-page-attribute/ but must be doing something wrong.
Am running latest version of Runway
Many thanks
Regards James
Use:
Thanks Drew .. that did the trick!