1

Quick 'how to' question for everyone around using Categories across multiple MSM sites.

Here's the situation:

  1. There is a 'master' (MasterSite) site, and 2 other 'sub-sites' (SiteA + SiteB).
  2. SiteA and SiteB both have a channel called Events.
  3. I'm using the standard Channel Entries tag on the MasterSite to show events from both SiteA and SiteB ... and of course using the site="SiteA|SiteB" parameter.
  4. SiteA and SiteB both have an 'Event Category' group setup.

The issue:

Everything works fine until I have a single list of category names (for filtering). SiteA has the following categories - Wine, Christmas, Mother's Day. SiteB has the following categories - Wine, Christmas, Father's Day.

When I list them out for filtering, I end up with duplicate names: - Wine - Wine - Christmas - Christmas - Mother's day - Father's day

I can see why this is happening, and where the issues are, and get why it has to work like that ... but I want to remove the duplicates! I can handle the filtering part (as I'm using Isotope I actually only need the category name to do the filtering!).

So here are my questions:

  1. Can I setup and share a single category group across the different sites?
  2. Is there an add-on that handles this issue?
  3. Is there a parameter or setting I've missed that 'removes duplicates'?
  4. Is there simply a better way to do this?

What I've come up with:

  1. Use javascript to remove duplicates on the fly.
  2. Use PHP to add in all categories into an array, removing duplicates, then list them out.

I'd rather do these things 'by the book' using built-in functionality if possible ... but am open to other suggestions!

Ready... steady... go!

:)

1 Answer 1

1

I'd do this with Stash. Use set_list to store each category and url title into an array, then use get_list with unique="yes" to remove the dupes:

{exp:stash:set_list name="cats" parse_tags="yes"}
    {exp:channel:categories style="linear"}    
        {stash:cat-name}{category_name}{/stash:cat-name}
        {stash:cat-url-title}{category_url_title}{/stash:cat-url-title}
    {/exp:channel:categories}
{/exp:stash:set_list}

<ul>
  {exp:stash:get_list name="cats" unique="yes"}
    <li><a href="{cat-url-title}">{cat-name}</a></li>
  {/exp:stash:get_list}
</ul>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.