Hi.
I would like to show a dynamic menu of the categories applied to the results page.
Let’s consider we have a total of 5 results.
If I use the following code:
{exp:channel:entries channel="products" style="linear" status="open"}
{exp:query sql="SELECT cat_name FROM exp_channel_data
INNER JOIN exp_category_posts
ON exp_category_posts.entry_id = exp_channel_data.entry_id
INNER JOIN exp_categories
ON exp_categories.cat_id = exp_category_posts.cat_id
WHERE exp_category_posts.entry_id = {entry_id}
"}
<li class="effects"><a href="#data-filter=">{cat_name}</a></li>
{/exp:query}
{/exp:channel:entries}I get duplicated values (eg. Category One Category Two Category Three | Category One Category Two Category Three)
Basically all the categories are listed once per result, but I would like to group them.
I’ve been trying also with this code:
{exp:channel:entries channel="products" style="linear" status="open"}
{exp:query sql="SELECT cat_name FROM exp_channel_data
INNER JOIN exp_category_posts
ON exp_category_posts.entry_id = exp_channel_data.entry_id
INNER JOIN exp_categories
ON exp_categories.cat_id = exp_category_posts.cat_id
WHERE exp_category_posts.entry_id = {entry_id}
GROUP BY cat_name"}
<li class="effects"><a href="#data-filter=">{cat_name}</a></li>
{/exp:query}
{/exp:channel:entries}without success…
Thanks in advance for your tips.
Also, if you have a simpler way to achieve the result, without using SQL statements but basic exp:channel:categories tags, please give me an advice.