Reefine
ExpressionEngine 2, ExpressionEngine 3, ExpressionEngine 4, ExpressionEngine 5, ExpressionEngine 6
Back to this add-on's main page
View Other Add-ons From Patrick Woodcock
Filtering Products by Categories defined in URL
Support (Resolved)
IC360 (Oliver Cannell)
|
Posted: 03 June 2020 10:06 AM |
|
|
|
Sorry if this an obvious one, but I’m not sure how to code it.
I have URLs like this already, which show the required Entry Categories in specific Segments: /products/*productype_url*/brand/*productbrand_url*/size/*productsize_url*
And I have my Reefine parameters like his:
{exp:reefine channel="products" parse="inward" category_url="{segment_2}|{segment_4}|{segment_6}"}
But I’m not getting any products output from this:
{entries} {exp:channel:entries channel="products"}
How do I achieve this?
Thanks a lot.
|
|
|
Patrick Woodcock
|
Posted: 03 June 2020 10:31 AM |
# 1
|
|
Developer
|
Hi Oliver
The category param doesn’t take pipes | I don’t think so you’ll need to use and if statement such as {if segment_2!=’‘}{segment_2}{/if} etc
Patrick.
|
|
|
Patrick Woodcock
|
Posted: 03 June 2020 10:41 AM |
# 2
|
|
Developer
|
If you can get the category ID then you can use pipe eg category=“2|4|5”.
|
|
|
IC360 (Oliver Cannell)
|
Posted: 04 June 2020 06:03 AM |
# 3
|
|
|
Thanks Patrick.
Yes, I’ve now used Low’s Seg2Cat plugin to enable the following method:
{exp:reefine channel="products" parse="inward" category="{segment_2_category_id}|{segment_4_category_id}|{segment_6_category_id}"} {entries} {exp:channel:entries channel="products" entry_id="{entry_ids}" pagination="bottom" limit="12"}
This outputs all the products that are included in ANY of the selected Categories.
|
|
|
IC360 (Oliver Cannell)
|
Posted: 04 June 2020 06:07 AM |
# 4
|
|
|
To output all the products that are included in ALL of the selected Categories, I’ve also tried this method, which seems to work nicely:
{!-- Pre-parse the current URL to build an Inclusive Category String, for use in the exp:channel:entries tag --} {preload_replace:filteredcategories="{if segment_2 != "any"}{segment_2_category_id}{/if}{if segment_4 != "any"}{if segment_2 != "any"}&{/if}{segment_4_category_id}{/if}{if segment_6 != "any"}{if segment_2 != "any" || segment_4 != "any"}&{/if}{segment_6_category_id}{/if}"}
{exp:reefine channel="products" parse="inward" category="{segment_2_category_id}|{segment_4_category_id}|{segment_6_category_id}"} {entries} {exp:channel:entries channel="products" category="{filteredcategories}" entry_id="{entry_ids}" pagination="bottom" limit="12"}
|
|
|
Patrick Woodcock
|
Posted: 06 June 2020 07:55 AM |
# 5
|
|
Developer
|
Nice one! Glad you got it sorted.
|
|
|