Forum
Filtering Categories
I've been following the Portfolio with Categories Video tutorial here: https://docs.grabaperch.com/video/v/portfolio-with-categories/
I've not been able to get the categories filtering page working where it shows a list of items in that category from the category slug. It always displays the list of categories (else)
category.php:
<?php
if (perch_get('cat')) {
perch_category(perch_get('cat'),array(
'template'=>'category_single.html'
));
perch_content_custom('Product Area', array(
'template' => 'product_listing.html',
'page'=>'/products.php',
'category' => perch_get('cat'),
));
} else {
perch_categories();
}
?>
My categories are set up as: 'products/metal-detectors/' which has the url or /category/products/metal-detectors/ I have the suspicion that something is going wrong here?
Debug:
Debug Message
SELECT * FROM perch2_pages WHERE pagePath='/category.php' LIMIT 1
Using template: /templates/pages/attributes/default.html
Using sub-template: /templates/pages/attributes/seo.html
SELECT setID FROM perch2_category_sets WHERE setSlug='' LIMIT 1
SELECT main.* FROM perch2_categories main WHERE 1=1 ORDER BY catTreePosition ASC
Using template: /templates/categories/category.html
What's the value of
?cat
when it comes through to your page?/products/metal-detectors/
That's odd, because it doesn't look like it's making it through:
Is that tested or expected? What does this output?
This doesn't output anything.
Ah ha - progress.
What does your rewrite rule look like? (Or are you using Runway?)
Normal Perch
Rewrites:
so URLs for category pages are: /category/products/metal-detectors/
So according to this:
you're setting the matched value as
?s=
on the query string. Therefore this:should be