Forum
Filtering item listing by category
Hi
I have a detail page with categories listed at the bottom. When a category is clicked it takes you to the category page which lists items related to that category.
This all works fine and it displays all content related to that Category.
What I am also trying to do is filter results by a Category from another Set as well as the one which has been selected on the detail page.
So that when a category is selected on the detail page of an Offer it only returns items which have been assigned to that main category is there a way for me to add the main category in to the category page code below?
<?php
if (perch_get('cat')) {
perch_category(perch_get('cat'),array(
'template'=>'category_single.html'
));
perch_content_custom('Offers', array(
'template' => 'item_listing.html',
'page'=>'/detail.php',
'category' => perch_get('cat'),
'sort'=>'itemTitle',
'sort-order'=>'ASC'
));
} else {
perch_categories();
}
?>
Is
cat
on your URL the full category path, or just the slug?It's the category path.
Ok, great. So you can just add it in if you use an array.
and so on.
Ah rite. I have tried to add that but the way I have used it brings back all items. How do I make it only bring back ones that match both the first set category and the category path passed through?
Set
Great
Thanks Drew thats it sorted now.