Forum
shop app page routes issue
Hi
I am getting conflicting issues with my page routes e.g. shop/products/[slug:cat] and shop/products/[slug:product]. Only one of these will work depending on the order. What am I missing here?
I did have a work around but it is broken now when using other features such as search. So not a solid fix.
Im sure this is simple but I just can't seem to crack it.
Will
Both those patterns will match the same thing, so whichever is first will be used. If you need to route them to different pages, you'll need to make something about the URL different, or use more specific patterns, or both.
Could you give me a few examples?
This is the fix I'm using..
My routes are - shop/item
shop/products
shop/item/[slug:product]
shop/products/[slug:cat]
shop/products/[slug:cat]/[slug:cat2]
shop/products/categories
For my fix, I made the 'item' sub-page to render single products. This way I don't get the confusion.
The template I for my listings has the link hard coded as <a href="/shop/item/<perch:shop id="slug" type="slug" />/"> to make sure it uses the path.
My category template has this <a href="/shop/<perch:category id="catPath" type="slug" />"> which gives the link https://localhost/shop/products/cards/colourful/ for example.
But the search template is quite different. It has this <a href="<perch:search id="result_url" />"><perch:search id="result_title" /></a> which gives a product link of https://localhost/shop/products/cats-002
Which no longer exists.
If I add in the /shop/item it adds it in the wrong place, thus breaking my link.
So, is there a way to fix this link or is what Im doing bad practice? I must say I'm struggling to find the right information on working with this part of the shop. Could you point me in the right direction?
Have you updated the product URL on the Settings page?
Little beauty! I knew it would be simple. Thanks again Drew!