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.

Display only parent category’s category_url_title?

August 03, 2011 3:11pm

Subscribe [3]
  • #1 / Aug 03, 2011 3:11pm

    philanthropyRT

    9 posts

    Hi there,

    Is there any way to limit a category_url_title to ONLY the parent, and not the children? And further more, is there a better way to manage child categories for filtering / sorting etc?

    In the below code, {category_url_title} outputs the Parent, then the first few letters of a child in the URI. It’s breaking things.

    [code]
    
            {exp:channel:entries channel="topic_list"}
            {il_{segment_2} limit="10" disable="member_data|pagination"}
                <a href="http://{path=topic/{categories}{category_url_title}{/categories}/{url_title}}">_                <div class="{blocksize}">_                        <h1 class="{categories}{category_url_title}{/categories}">{title}</h1>_                        {article_excerpt}_                </div>_            </a>        
            {/il_{segment_2}}
            {/exp:channel:entries}

    Thanks!

    Moved to Community Help forum by Moderator

  • #2 / Aug 04, 2011 8:20am

    Sue Crocker

    26054 posts

    Welcome to the ExpressionEngine forums!
    Here’s a very stripped down version of your code:

    {exp:channel:entries channel="news"}
    <h3>{title}</h3>
    <p>{categories}<br />
    {if parent_id == 0}<br />
    {category_url_title}</p>
    
    <p>{/if}<br />
    {/categories}<br />
    {/exp:channel:entries}

    You test for parent_id of zero, which means you get just the parent and not the children.

    Does that help?

  • #3 / Aug 04, 2011 10:48am

    philanthropyRT

    9 posts

    Thanks for the reply, Sue!

    Well I’ve advanced a bit further in my problem since I first posted yesterday. Maybe you can help me where I"m stuck now?

    I’m attempting to display multiple categories with 1 template, while harnessing Low’s seg2cat.
    Essentially, I have 3 category groups. On a template displaying a permalink entry, the primary category is being called using seg2cat

    Each entry has 2 categories assigned to it, from different category groups. The primary, then the secondary. I’m not using Children categories because there would be redundancy of the same children for each parent. On the side of the page, I’m wanting pull related articles—one set from the Primary Category ( category=”{segment_2_category_id }” ) and the other from the secondary category (?).

    As such, my opening exp loop looks like so:

    {exp:channel:entries channel="articles" limit="1" category="{segment_2_category_id}" url_title="{segment_3}" dynamic="no"  }

    The only problem is, I can’t figure out how in the hell to call the 2nd category.

    Any thoughts?

    Many Thanks,
    A

  • #4 / Aug 04, 2011 4:07pm

    Sue Crocker

    26054 posts

    Since you’re using a third party solution, I’m going to move this to the Community Help forum for additional community support.

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

ExpressionEngine News!

#eecms, #events, #releases