Runway Shop Slug for Product

  • I am creating a site using Perch Runway and the Shop app, but I am having trouble using a slug with the Perch routing for products. Can someone shed some light on this for me? Here is what I am trying to do:

    My product template has this slug template tag:

    1. <perch:shop id="slug" type="slug" editable="true" indelible="true" label="Slug" for="title" order="10" divider-before="Meta data" />

    I have a master page called product.php which has the following code in it, but I don't know how to isolate that slug where I have 'slug' below (if that makes sense):

    1. <?php
    2. perch_shop_product('slug', [
    3.     'template' => 'products/product_detail.html',
    4. ]);
    5. ?>

    Naturally, that returns nothing, if I replace 'slug' with 'example-product' (which is the slug generated for that product), it loads. But I need to pull the slug value for the product into here, which is the part of the puzzle I'm missing.

    This is the page I was referencing in the docs:…ducts/perch-shop-product/

    Any help would be greatly appreciated!

  • Thank you for the speedy reply Hussein!

    Since I am using Runway, I was hoping I could just use /products/example-product, is Runway capable of that? We tend to use Slim PHP for our normal Perch routing, so using ?s=* is not what I expected from Runway, but clean URLS - do I have to use perch_get('s') in this instance only?

    Thanks again,

  • Yes, you'd be able to use clean URLs. You would set up a route to the page (Pages > your page > location tab).

    Your route in this case would be (no slash at the start):

    1. products/[slug:s]

    slug is the type of value the URL segment represents. s is what you are naming this URL segment (so you can use it on the page). You can get the value of this segment with perch_get() just like you would with URL query parameter.