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.

Trying to display entry's category

January 25, 2012 10:32pm

Subscribe [6]
  • #1 / Jan 25, 2012 10:32pm

    EnergyFreak

    102 posts

    Hi,

    I am trying to display the category of my listing, I tried different codes but none of them worked. First let me explain what I want to do. I want to first display the category where the entry was assigned to and then on a separate line I want to display its parent category.

    This is the code I used, which in my head makes sense, but for some reason nothing is showing up.

    {exp:channel:categories show="{category_id}"}{category_name}{/exp:channel:categories}

    I believe this bit of code would only show the category it was assigned to and not the parent category, but it is a start.

    Let me know if I am doing something wrong.

    Thanks !

  • #2 / Jan 26, 2012 4:59am

    danieljohnbarnes

    151 posts

  • #3 / Jan 26, 2012 5:57am

    Pv Ledoux

    95 posts

    for exp:channel:categories the channel_name is required I think.

  • #4 / Jan 26, 2012 8:57am

    Boyink!

    5011 posts

    Daniels answer will net you the categories assigned to the entry.  You’ll only get the parent if you have “Auto assign category parents” set to “Yes” in your Channel Global Prefs.

  • #5 / Jan 26, 2012 9:37am

    EnergyFreak

    102 posts

    Okay so it worked for displaying only the category it was assigned to if I have “Auto assign category parents” to “no”. The problem is I still need my entry to be assigned to a parent and a child for search reasons. Is there a way I can filter out the parent from one line and have a way to filter out the child in the other line?

    Thanks.

  • #6 / Jan 26, 2012 12:05pm

    e-man

    1816 posts

    Have a look at this add-on http://devot-ee.com/add-ons/gwcode-categories ,it may help.

  • #7 / Jan 26, 2012 12:17pm

    Boyink!

    5011 posts

    Okay so it worked for displaying only the category it was assigned to if I have “Auto assign category parents” to “no”. The problem is I still need my entry to be assigned to a parent and a child for search reasons. Is there a way I can filter out the parent from one line and have a way to filter out the child in the other line?

    Thanks.

    How are you doing search?  The EE search engine doesn’t see categories.

    Overall EE’s native categories are simple filters, the whole notion of parent/child only really represented in the channel:categories tag pair, not the channel:entries {categories} looping pair.

  • #8 / Jan 26, 2012 12:38pm

    EnergyFreak

    102 posts

    @e-man - Thanks for the suggestion, so far it works perfectly, except for some reason I think the items are trying to automatically display as a list, which I do not want of course. I will keep playing with it until I can figure out how to remove the line underneath the category.

    @Boyink! - I don’t mean an actual search, I will have a store and there will be a possibility to filter out entries with the channel categories.

  • #9 / Jan 27, 2012 3:11am

    Laisvunas

    879 posts

    Hi,

    Try Entry Categories

    Entry Categories allows you to output info about categories the entry was posted into.

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

ExpressionEngine News!

#eecms, #events, #releases