Forum
View All using URL parameter
Last one for today. I now have the following on my products list page:
if (perch_get('price')) {
perch_shop_products([
'template' => 'products/paginated-list.html',
'paginate'=>true,
'count'=>18,
'sort'=>'price',
'sort-order'=>perch_get('price'),
'sort-type'=>'numeric',
'category' => 'products/' . perch_get('family'),
]);
}
else {
perch_shop_products([
'template' => 'products/paginated-list.html',
'paginate'=>true,
'count'=>18,
'sort'=>'priority',
'sort-order'=>'ASC',
'sort-type'=>'numeric',
'category' => 'products/' . perch_get('family'),
]);
}
Using your method of adding a hidden input on the form, I can now output another parameter called view
. This gives a URL like:
https://mysite.com/?family=something&price=asc&view=all
When view is set to all
, I need to switch pagination
to false, and I guess remove the count
too. What is the best way of going about this? I can do it but with loads of elseif
s and &&
which seems a bit clumsy
You should be able to do:
Hi Drew,
Thanks for the pointer. I have it working now, though it could possibly be a bit cleaner. Do I need to do the variable setting or is there a better way?
If it's working then I think you're probably good.