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.

Category Parent Name

June 13, 2011 11:48pm

Subscribe [3]
  • #1 / Jun 13, 2011 11:48pm

    ustict

    6 posts

    I have a problem here with category parent name, I want to show parent name instead of parent id {parent_id}, how can I call parent name?

    Parent name (Category A), Sub category (Category 1)

    {exp:channel:category_heading}{if parent_id}{category_name},{/if}{category_name}{/exp:channel:category_heading}{/exp:channel:entries}

    the html will show

    Category 1, Category 1 insteads of Category A, Category 1

  • #2 / Jun 14, 2011 3:51am

    see next post

  • #3 / Jun 14, 2011 3:53am

    I guess there is no tag to display this, you need to use query.

    {exp:channel:category_heading}
    {if parent_id}
       {exp:query sql="SELECT cat_name FROM exp_categories WHERE cat_id = '{parent_id}'"}
        {cat_name},
       {/exp:query}
    {/if}
    {category_name}
    {/exp:channel:category_heading}


    Srikanth

  • #4 / Jun 14, 2011 3:39pm

    Sue Crocker

    26054 posts

    Thanks for the assist, Srikanth.

    ustict, will the query work for you?

  • #5 / Jun 15, 2011 12:07am

    ustict

    6 posts

    It worked, thanks for the help, srikanth aetukuri 😊

    you missed out (”) after {parent_id}’
    hope you can edit it for our future reference. thanks again.

  • #6 / Jun 15, 2011 2:09pm

    Sue Crocker

    26054 posts

    Glad that worked for you… If anything else comes up, please do let us know in a new thread..

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

ExpressionEngine News!

#eecms, #events, #releases