Forum
404 Routing Shop Categories
I have a navigation bar that routes categories from the set "Products" with the following path: /products/cat/subcat/etc The pages in the nav are showing up with proper links, and the /products page which displays the product list from a particular category currently has this function, but I end up with a 404 error on the page.
<?php
perch_shop_products ('Products', array[
'count' => 10,
'category' => perch_get('cat'),
]);
?>
Hello Kevin,
Do you have any routes set up for
/products
? If not, go to the page and add the routes under the Location tab.https://docs.grabaperch.com/runway/routing/
Yes, I originally routed the page to /products/[slug] but didn't know which tags to use so that it would recognize more than one slug for categories with children.
If you only look for parent categories, you would use
products/[slug:cat]
. If you want to include sub categories too, check out this thread: https://forum.grabaperch.com/forum/02-13-2018-perch-shop-url-adviceThanks - I have used the link you provided to adjust my routes so that it shows
products/[slug/slug:catPath]
. Now the pages don't return a 404 when the category links are pressed, they just show a completely blank page as if the template is not being pulled. Below is my master page for the product category listing and the list template.Master Page:
Product List Template:
What routes do you have configured that start with
products
, and what order are they in?products/[slug:catPath]
Then
products/[slug/slug:catPath]
That looks ok. If you turn on debug, what does it output for the page that isn't working? The routing information is at the top of the debug.
You are using
array[]
which I think would result in a syntax error.You also have an extra argument. You are using
perch_shop_products(string, array)
- the first argument should be an array as far as I know.One last thing,
perch_get('cat')
in your case doesn't return the full category path. It would returncategory/subcategory
rather thanset/category/subcategory/
.Try this:
I have adjusted the code in the master with the template set to
'template' => 'products/list.html',
- now the page is loading the header and footer properly, but the template has no information in it and shows up blank. The debug results seem to be using the template properly, but there's not even the H1 from the template that should output regardless of content beneath.If
products/[slug:catPath]
is your route, you need to useperch_get('catPath')
notperch_get('cat')
.Thank you guys, it's working now!