Forum

Thread tagged as: Question

Product detail page

Building my first Perch Shop. I've followed the steps for getting the Shop installed and everything seems to work just fine. Ive managed to list all my products but when clicking on a product a get the "Sorry, that page could not be found." I had a routing problem earlier and fixed that but this also seem like a routing problem? I have put my files in the /template/pages/ folder. Im well known with Perch but not Perch Runway. Is there a way to build shops with Runway on the root or is it prefered to refer to the /template/pages/ folder?

Erick Green

Erick Green 0 points

  • 5 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

Have you added a page to show your product detail?

I have not. Can't find any article on how I do that. Ive downloaded the Nest Running Club demosite to see if i can pick up something from that, but the product.php page is empty at the demosite too.

Drew McLellan

Drew McLellan 2638 points
Perch Support

That site doesn't actually have a page for product detail.

Create you page, with a route matching the URL you want your product detail pages to display on.

Then use perch_shop_product() to display the product details.

https://docs.grabaperch.com/addons/shop/products/functions/perch-shop-product/

Okay so Ive created the product page and got the routing right. It shows all my products detail, not just the one ive choosed. On previous Perch sites we build we use the slug alot with perch content. Do I have to get the slug here to? If i do, how to do it? Tried a few different ways but cant get it to work.

Drew McLellan

Drew McLellan 2638 points
Perch Support

Yes, that's right. As you've provided no detail I'll just have to guess, but if you have a URL like

/products/my-product-slug

You might match that with the route like

products/[slug:productSlug]

And you'd read that slug in using

perch_get('productSlug');

Which you could use like this:

perch_shop_product(perch_get('productSlug'));

Works perfect. Thanks! Would you recommend to keep the pages in templates with the original folder structure instead of create the pages on root?

Drew McLellan

Drew McLellan 2638 points
Perch Support

Yes, that's how to structure pages with Runway. More here: https://docs.grabaperch.com/runway/structure/