ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

How do I create a list of distinct categories for related entries of a single channel entry?

October 11, 2013 12:22pm

Subscribe [2]
  • #1 / Oct 11, 2013 12:22pm

    springworks

    4 posts

    I have the following setup:

    1. Each entry in a parent channel a number of related child entries from a child channel. These use a standard EE relationship field called “children”.

    2. The parent channel does not use categories.

    3. Each entry in the child channel has a category associated to it.

    4. There will be a some child entries related to a single parent entry from the same category.

    Given a single parent channel entry, how do I generate a list of the categories for its related child entries without including duplicates if more than one child entry has the same category?

    Here’s what I’ve tried so far, which results in duplicate entries when child entries are in the same category.

    {exp:channel:entries limit="1" channel="parent_channel" disable="{sn_disable_standard}" required="Yes"} 
        {children}
            {children:categories}
                {category_name}
            {/children:categories}
    
        {/children}
    {/exp:channel:entries}

    Is there a plug-in that I can use to store the results in a variable, then strip out the duplicate entries?

    Or can this be done using standard EE tags? Or even the query module?

  • #2 / Oct 11, 2013 4:35pm

    Boyink!

    5011 posts

    I don’t 100% follow, but it seems to me that mixing relationships and categories just doesn’t feel right in this case.

    Why not another channel & set of relationships rather than categories?

  • #3 / Oct 11, 2013 4:46pm

    springworks

    4 posts

    You might be right. Maybe I need to rethink the data model for this.

    I’ll have a rethink.

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases