Listed product slug not linking to detail template
In Perch Shop I have listed product items all linking to their respective slug URLs. However when I click through on these it's failing to display them in the product detail template. What am I doing wrong? I am calling a variable in the function called 'product'. Does this relate to Runway setup? Unsure of this.
list template button linking to product page
<a href="/products/<perch:shop id="slug" type="slug">/"" class="button shop-button w-button">find out more</a>
product detail page
<div class="right-col w-col w-col-8">
<?php perch_shop_product(perch_get('product'),[
'template' => 'products/product_detail.html',
'filter' => 'slug',
'match' => 'eq',
'value' => perch_get('product')
]); ?>
</div>
product_detail.html template
<div class="blog-image-wrapper">
<h2 class="shop-product-heading"><perch:shop id="title" type="text" /></h2><img src="<perch:shop type="image" id="prodImage1" class="blog-feature-image"></div>
<div class="gallery-flex-wrap"></div>
<div class="blog-post-wrapper">
<<perch:shop id="description" type="text" />
</div>
<div class="shopify-wrapper">
<div class="shopify-buy-price">
<div class="text-block">€<span class="price"><perch:shop id="price" type="shop_currency_value"</span> inc VAT</div>
</div>
<div class="w-form">
<form id="email-form" name="email-form" data-name="Email Form"><select id="Box-Size" name="Box-Size" data-name="Box Size" class="shopify-select w-select"><option value="">Choose Box Size</option><option value="First">First Choice</option><option value="Second">Second Choice</option></select></form>
<div class="w-form-done">
<div>Thank you! Your submission has been received!</div>
</div>
<div class="w-form-fail">
<div>Oops! Something went wrong while submitting the form.</div>
</div>
</div><a href="#" class="button buy-now w-button">add to cart</a></div>
Diagnostics
Perch Runway: 3.1.2, PHP: 7.1.20, MySQL: 5.6.39, with PDO
Server OS: Linux, cgi-fcgi
Installed apps: content (3.1.2), assets (3.1.2), categories (3.1.2), perch_blog (5.6.1), perch_shop_orders (1.2.6), perch_shop_products (1.2.6), chirp_seo (1.2.1), perch_shop (1.2.6), perch_members (1.6.4)
App runtimes: <?php $apps_list = array( 'content', 'categories', 'perch_blog', 'perch_members', 'perch_shop', ); ?>
PERCH_LOGINPATH: /perch
PERCH_PATH: /var/www/vhosts/142/1004491/webspace/httpdocs/perch
PERCH_CORE: /var/www/vhosts/142/1004491/webspace/httpdocs/perch/core
PERCH_RESFILEPATH: /var/www/vhosts/142/1004491/webspace/httpdocs/perch/resources
Image manipulation: GD Imagick
PHP limits: Max upload 32M, Max POST 32M, Memory: 256M, Total max file upload: 32M
F1: 3b606135b33e6a102526838f4152a807
Resource folder writeable: Yes
HTTP_HOST: www.lirchocolates.com
DOCUMENT_ROOT: /var/www/vhosts/142/1004491/webspace/httpdocs
REQUEST_URI: /perch/core/settings/diagnostics/
SCRIPT_NAME: /perch/core/settings/diagnostics/index.php
Have you set up a route for
/product/slug
?Hi Drew, do you mean in Perch Runway settings? The product URL is set to; /product/{slug}
It loads the /product/slug into the address bar, but it displays a 404 page not found error.
Perhaps I'm misunderstanding the Perch Shop on Runway. By Routing, do you mean the shop's product detail page require some sort of master page like you would a pages app template? therefore allowing dynamic pages to be displayed? If so do you have examples of this or do I just work off the default?
Yes, there's a description of how it works here: https://docs.grabaperch.com/runway/routing/
Hi Drew, thanks for that. Something that's jumping out at me in the docs in "Find the page and click on Page Options" My /shop/product.php or /shop/index.php pages are not appearing in my Pages Listing on the Perch control panel, so therefore I can't action this. It seems odd as I've included the Perch string on the top of each page. Should they be appearing?
I've also tried with this string
When I click on the pages section within my Perch Runway I see a Routes section, but I don't have the ability to add new routes? Why?
Hello Cromac,
If you are using Runway, you should be creating master pages in
templates/pages
and adding pages via the control panel: https://docs.grabaperch.com/runway/core-tasks/master-pages/Hi Hussein, Thanks for your response. I've added a new master page here called product.php, this is the code below:
In Perch Admin I've updated the route pattern URL for this master page to be :
I've updated the list template to point to:
This still doesn't work. How do I make the unique detail page pick up this master page template? It's still giving me a page 404
Since you are using Runway, you don't to include the Perch runtime file. So you can remove this:
Since you are using
perch_get('product')
, your route should be:Hi Hussein, No problem. Removed that string from the products.php master template and updated the route URL pattern to
Issue still remains; clicking on an item in the listing page, loads the URL expected but not the page; leaves a 404 error.
You also need to remove the slash at the start.
It was removed in the URL to begin with. I tested with both slash removed and present and it made no difference.
Just to note in Perch Admin settings for Product URL I also have this:
Again it makes no difference. It's like the product is not able to take to the master page?
So you have:
templates/pages
/shop/products
) - can you confirm you can visit this page/shop/products
?shop/products/[slug:product]
/shop/products/my-product-slug
but you're still getting a 404?Okay, so obviously the successful product page I was seeing was the one that was there on the server already. I deleted this and attempted to add a page called product with the path /shop/product.php and it is failing. I also re-updated it's URL pattern to shop/products/{slug} and it's still failing with a 404. So it is not recognising this master template?
When you go to the page in the control panel and click on the "Location" tab, what do you see in the "Path" field? And what do you see in the "URL pattern" field?
When I created the page using the product.php master template, the debug tells me I'm using a different template... why?
The URL pattern field is blank, so I add in:
If I'm adding a page called Product, what should the URL segment read?