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 category name

March 12, 2011 7:37pm

Subscribe [5]
  • #1 / Mar 12, 2011 7:37pm

    Youthworks

    47 posts

    Hi, I think I have a fairly simple question

    I got a index page listing all category entries
    domainname.com/library/topic/literature (the magic category name is ‘topic’) and its listing all the entries in the category ‘literature’.

    But on the top of the page I would like to display the name of this category. I could just put

    {segment_3}

    but that its not always good if I have a segment 3 that is more than one word (example: life-on-earth) and of course I could remove dash by using a plugin to remove it, but then again, the the category name is not formated correctly with caps.

    Is there anyway I can make sure I use the category_name as the header?

    Cheers

  • #2 / Mar 12, 2011 8:13pm

    Tom Jaeger

    461 posts

    If I’m following you correctly, you should be able to use Low’s Seg to cat plug in.  In conjunction with the following to accomplish this.

    {exp:channel:categories id="{segment_3_category_id}"}
    {category_name}
    {/exp:channel:categories}

    http://loweblog.com/software/low-seg2cat/

    -Tom Jaeger

  • #3 / Mar 12, 2011 8:43pm

    Youthworks

    47 posts

    Hi, thanks for the tip, I think that would work, except, struggling just doing

    {exp:channel:categories style="linear" show="4"}{category_name}{/exp:channel:categories}

    ID 4 is a subcategory of 3, when I tested

    {exp:channel:categories style="linear" show="3"}{category_name}{/exp:channel:categories}

    it worked, but when I tried ID 4 it wouldn’t display. I found this strange

  • #4 / Mar 13, 2011 1:43pm

    Kevin Cupp

    791 posts

    If you want to show sub categories, set parent_only=“no” in your exp:channel:categories tag.

  • #5 / Mar 13, 2011 5:58pm

    Youthworks

    47 posts

    Kevin, thanks for that time,
    I wish it was that easy, this is the code I’m using

    {exp:channel:categories style="linear" parent_only="no" show="4"}{category_name}{/exp:channel:categories}

    and it’s still not working :(

  • #6 / Mar 13, 2011 6:04pm

    Mark Bowen

    12637 posts

    You need to surround {category_name} with the {categories} tag pair.

    {exp:channel:categories style="linear" parent_only="no" show="4"}
    
    {categories}
    {category_name}
    {/categories}
    
    {/exp:channel:categories}


    Best wishes,

    Mark

  • #7 / Mar 13, 2011 8:48pm

    Youthworks

    47 posts

    Yes of course, forgot to put that in that code on this forum, put I was using this code still without result:

    {exp:channel:categories style="linear" parent_only="no" show="4"}{categories}{category_name}{/categories}{/exp:channel:categories}

    Thanks for helping

  • #8 / Mar 13, 2011 8:55pm

    Mark Bowen

    12637 posts

    Oops sorry. I could have sworn above I saw you using a Channel entries tag but I must have been reading another forum post as I can see that you’re using the categories tag.

    Have you tried supplying the channel parameter to the channel:categories tag?

    Best wishes,

    Mark

  • #9 / Mar 14, 2011 9:50am

    Sue Crocker

    26054 posts

  • #10 / Mar 14, 2011 10:13am

    Mark Bowen

    12637 posts

    Also don’t forget the Category Heading Tag.

    Best wishes,

    Mark

  • #11 / Mar 14, 2011 11:11am

    Sue Crocker

    26054 posts

    Thanks for adding that, Mark.

    Robert - does this info help?

  • #12 / Mar 14, 2011 5:46pm

    Youthworks

    47 posts

    Unfortunately still not working.
    I tried both Sue and Mark’s suggestion and still doesnt give any output.

  • #13 / Mar 14, 2011 5:53pm

    Youthworks

    47 posts

    YES!!!! Finally, Start working when I specified ‘channel’

    {exp:channel:category_heading channel="library"}
    {category_name}
    {/exp:channel:category_heading}

    Thanks for great help - a specially thank to Mark who put me on the track to successful code!

    Cheers,

  • #14 / Mar 15, 2011 10:35am

    Sue Crocker

    26054 posts

    Glad things are working again.. Don’t hesitate to post again as needed.

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

ExpressionEngine News!

#eecms, #events, #releases