Forum

Thread tagged as: Question, Configuration, Shop

Shop product detail page in regular Perch.

I'm attempting to set up a product detail page and have pretty much the same query as this poster but in regular Perch.

I have /shop/products/{slug} set as my product URL in the dashboard.

On my list page the unaltered <a href="/shop/products/<perch:shop id="slug" type="slug" />/">.

And on the details page <?php perch_shop_product(perch_get('product'));?>.

But as I don't have routes available, is the best approach to set a rewrite in .htaccess to point to a product detail page?

I have my shop file structure as below so far.

Perch Shop file structure

Is that the/a correct way to structure them?

Mark Phoenix

Mark Phoenix 0 points

  • 5 years ago

Hi Mark

I'm working on a small shop in regular Perch at the mo and htaccess is the way to go for non-runway. Something like;

RewriteRule ^shop/products/(.+)$ shop/product.php?product=$1 [L]
Rachel Andrew

Rachel Andrew 394 points
Perch Support

Wayne is correct, if you aren't using Runway then you need to set up your rewrite rules yourself in .htaccess.

You can have any structure you like, just make sure any paths in your templates are correct in terms of what you have decided to do.

Thanks Rachel & Wayne. Hoping I can bump my client up to Runway eventually, eager to give it a try.

I've used that .htaccess rule as is and it's redirecting to the correct page, but it's not displaying a product. Is there something else I should be doing to pass the slug into perch_shop_product(), as I'm not getting anything from perch_shop_product(perch_get('product')). It'll be something obvious won't it...

Rachel Andrew

Rachel Andrew 394 points
Perch Support

You need to check whether the value you expecting is getting to the page and then se what is being passed to that function. Step through what is happening until you find the problem.

As the product page is in a folder... does the runtime have the current path? ie;

<?php include('../perch/runtime.php');?>

Only mentioning as this caught me out the first time...

Runtime is working fine, thanks though Wayne. Still working on it!!

Turns out the trailing slash in <a href="/shop/products/<perch:shop id="slug" type="slug" />/"> was being output in <?php perch_shop_product(perch_get('product'));?>. So removed it and it's working fine. Knew it would be something simple.

Thanks for your help.