Module, Plugin

Archived
Forum
(read-only)

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)
IC360 (Oliver Cannell)

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
# 1
Developer
Patrick Woodcock

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
# 2
Developer
Patrick Woodcock

If you can get the category ID then you can use pipe eg category=“2|4|5”.

IC360 (Oliver Cannell)
# 3
IC360 (Oliver Cannell)

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)
# 4
IC360 (Oliver Cannell)

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
# 5
Developer
Patrick Woodcock

Nice one! Glad you got it sorted.