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 parent category name of child

November 13, 2012 9:35am

Subscribe [1]
  • #1 / Nov 13, 2012 9:35am

    Eastwood Design

    605 posts

    When I am viewing a child category in segment 3 I want to be able to display the parent category name in my template.

    The following does NOT work.  am I missing something?

    {exp:channel:categories channel="products" show_empty="no" dynamic="yes" parent_only="yes" style="linear"}{category_name}{/exp:channel:categories}
  • #2 / Nov 13, 2012 9:41am

    Eastwood Design

    605 posts

    looks like I may need to use a query.

    Can anyone guide me in the right direction?

    I can easily get the parent id using Lows seg2cat {segment_3_category_parent_id} but how do I work that in a query to display the category name of the id?

  • #3 / Nov 13, 2012 9:52am

    glenndavisgroup

    436 posts

    Try removing the dynamic=“yes” parameter. The categories module doesn’t have this parameter.

    Mike

  • #4 / Nov 13, 2012 9:55am

    Eastwood Design

    605 posts

    solved with some help from Low

    {exp:query sql="SELECT cat_name FROM exp_categories WHERE cat_id = '{segment_3_category_parent_id}'"}
    Parent name: {cat_name}
    {/exp:query}
  • #5 / Nov 13, 2012 9:58am

    Eastwood Design

    605 posts

    Try removing the dynamic=“yes” parameter. The categories module doesn’t have this parameter.

    Mike

    removing the dynamic=“yes” did not help, it still displayed all the parents in that group, not just the one that was active.

  • #6 / Nov 15, 2012 11:10am

    Dan Decker

    7338 posts

    Hi Eastwood Design,

    I’m glad you were able to come to a solution here.

    Is there anything else I can assist you with?

    Cheers,

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

ExpressionEngine News!

#eecms, #events, #releases