I don’t even know if I’m asking for the right thing. What I have is a list of categories and those categories will be links to filter items. Here’s what I’m starting with:
{foreach from=$items item=entry}
{strip}
{foreach from=$entry->categories item='one_category'}
{foreach from=$categories item='one'}
{if $one_category.name == $one.name}
{$one.name}
{$one.name|munge_string_to_url}
{/if}
{/foreach}
{/foreach}
{/strip}
{/foreach}
Here’s a better version:
So this lists out every instance used on a page. The intention is to list the instance 1x, if there is an instance.
<ul>
<li><a class="active" href="#" data-filter="*">All</a></li>
{foreach from=$items item=entry}
{foreach from=$categories item='one'}
<li><a href="#" data-filter=".{$one.name|munge_string_to_url}">{$one.name}</a></li>
{/foreach}{/foreach}
</ul>
This shows all the items but it’s not correct, if there are 20 articles assigned to one category, it lists it 20 times, if there are 5 articles assigned to one category it will list it 5 times. I just want one each for each matching string. Not a clue as to what to do. Thank you for any insight you can provide.
Let’s try this.
Basically, the idea is to keep a record of categories you’ve already added to the list and not add them again. I do this through $tempCat which starts as nothing and concatenates any category that’s not in it. So subsequent checks see the category is already added and skips it.