Forum

Thread tagged as: Question, Shop

Perch Shop Category list and detail

HI all

Has anyone successfully listed all shop categories and then once a category is clicked a page with all items in that category are displayed

without a static page for each category looking for a dynamic solution

Thanks

Ant

Anthony Elleray

Anthony Elleray 2 points

  • 5 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

Absolutely. Where are you running into problems?

To filter products by category:

perch_shop_products([
    'category' => 'products/pyjamas',
]);

or if you're pulling the category from the URL, something like:

perch_shop_products([
    'category' => 'products/'.perch_get('category'),
]);

Hi Drew its the page that lists all the shop categories im having issues

i have this

shop/index.php

if (perch_get('s')) {

 // Detail mode
    perch_shop_products([
        'category' => 'products/'.perch_get('category'),
    ]);
} else {

 // List mode
    perch_categories(array(
        'template'=>'test.html',
    ));
}

test.html

<perch:before><ul></perch:before>
<li style="margin-left: <perch:category id="catDepth" type="hidden" />0px;">
    <a href='?s=<perch:category id="catSlug" type="slug" for="catTitle" />'>
    <h4><perch:category id="catTitle" type="smarttext" label="Title" required="true" /></h4>
    <perch:category id="catSlug" type="slug" for="catTitle" suppress="true" />
    <perch:category id="desc" type="textarea" label="Description" editor="markitup" markdown="true" size="s" />
    </a>
</li>
<perch:after></ul></perch:after>

Sorted it missed out

'category' => 'products/'.perch_get('category'),
'category' => 'products/'.perch_get('s'),