Take the 2-minute tour ×
ExpressionEngine® Answers is a question and answer site for administrators, end users, developers and designers for ExpressionEngine® CMS. It's 100% free, no registration required.

I have 3 category parents with several children in each.

For a single entry product page, I would like to list which categories the product belongs to (children only), with a single header for each category parent:

Publisher: (parent id 22) Designer: (parent id 45) Genre: (parent id 8)

There could be multiple children categories for Designer and Genre.

Ideally I would like to use conditional statements that spit out:

if publisher is checked then <p>Publisher: <a href="#">publishercategoryname</a> </p>

if designer is checked then <p>Publisher: <a href="#">designercategoryname1</a>, <a href="#">designercategoryname2</a>, <a href="#">designercategoryname3</a> </p>

if genre is checked then <p>Genre(s): <a href="#">genrecategoryname1</a>, <a href="#">genrecategoryname2</a>, <a href="#">genrecategoryname3</a> </p>

I would like the parent to show up just once, with the children category names nested.

Any help would be greatly appreciated.

Thanks!

share|improve this question

migrated from stackoverflow.com Mar 25 '13 at 7:11

This question came from our site for professional and enthusiast programmers.

2 Answers 2

up vote 2 down vote accepted

Whilst you can do some complicated stuff with GW Categories, I would probably first use separate category groups for these three things instead of nesting parent-child categories. It would simplify things greatly and create better separation of concerns, since your top-level categories are not semantically related to each other - you're basically just faking headings which would be better suited as individual category groups.

{exp:channel:entries channel="example" disable="categories|member_data|pagination"}
    <h1>{title}</h1>
    {exp:gwcode_categories entry_id="{entry_id}" style="linear"}
       {if group_start}<p>{cat_group_name}: {/if}
       <a href="{path=category/{cat_url_title}}">{cat_name}</a>
       {if group_end}</p>{if:else} ,{/if}
     {/exp:gwcode_categories}
{/exp:channel:entries}
share|improve this answer
    
I agree with you. I just created new category groups for each, instead of using parents. Still not sure how to code it so that I can get the categories for each group id listed though. They may not always be populated, so needs a conditional, and I want them listed with the group id name only once. Any thoughts? –  Alissa J. Robinson Mar 24 '13 at 13:35
    
edited answer to add an example - as with most things to do with EE categories, using the GW plugin will make this easier. –  James Smith Mar 24 '13 at 16:19
    
That works perfectly! Thanks James! –  Alissa J. Robinson Mar 25 '13 at 9:37

This excellent add-on http://devot-ee.com/add-ons/gwcode-categories will do exactly what you need. Check it out!

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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