1

EE2.7.2

I have a native relationship field 'related_products' pulling in multiple entries from a products channel. Most products are in 2 top level categories - group_id 1 and group_id 2. I want to pass the category_url_title in my link.

The code below returns both the categories in the url:

{exp:channel:entries channel="featured_products" dynamic="no" limit="1" url_title="featured" status="open" disable="pagination|member_data|category_fields"}
{related_products limit="12"}
    <a href="{site_url}brands/{related_products:categories}{category_url_title}{/related_products:categories}/{related_products:url_title}" title="View product details">LINK</a>
{/related_products}
{/exp:channel:entries}

If I add 'related_products:categories limit="1"' to the code as below, it will return just one category - always from only group_id 1.

{exp:channel:entries channel="featured_products" dynamic="no" limit="1" url_title="featured" status="open" disable="pagination|member_data|category_fields"}
{related_products limit="12"}
    <a href="{site_url}brands/{related_products:categories limit="1"}{category_url_title}{/related_products:categories}/{related_products:url_title}" title="View product details">LINK</a>
{/related_products}
{/exp:channel:entries}

I can't seem to find a way to filter the 'related_products:categories' to show the second group of categories.

Can anyone help?

| improve this question | | | | |
1

I'm not sure I get what you finally want, but to show the second group of categories try using the show_group parameter to the categories tag (with the category group id):

{related_products:categories show_group="2"}{category_url_title}{/related_products:categories}
| improve this answer | | | | |
  • Thanks! That worked. After reading the docs, I'd tried all the other tags listed without success. This really needs to be added to the Relationship Docs page. – xenowebdev Apr 11 '14 at 21:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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