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 a single Category Image (given the Category ID)

October 16, 2012 5:40am

Subscribe [3]
  • #1 / Oct 16, 2012 5:40am

    I’m probably just being thick… but how do I output the Category Image of a single Category, given the Category ID?

    I was expecting it to be something like this:

    {exp:channel:categories category_id="8" style="linear"}
     {category_image}
    {/exp:channel:categories}
  • #2 / Oct 16, 2012 4:53pm

    Robin Sowell

    13255 posts

    That should work fine.  What version are you using?  And if you go to the category edit page and edit id 8, make sure it shows an image.  And you might resave it.  Also- output the {category_name} as well- just so you know for sure it’s outputting the right category.

  • #3 / Oct 17, 2012 4:59am

    EE v2.5.3
    For some reason this code outputs all the categories.
    Am I able to just out the details for one specific category?

  • #4 / Oct 17, 2012 4:52pm

    Robin Sowell

    13255 posts

    Man- I should learn to focus.

    First- typically when you want to show just one category, you use the channel heading tag- but it is ONLY dynamic- you can’t specify with category it pulls.  So it may/may not be what you need.

    Second- I didn’t even see it first time around, but if you’re using the categories tag and want to specify which category(s) to show?  You need to use the show parameter, there is no category_id parameter.  Though I will admit- that name would have been more consistent with where we do it elsewhere.

    Get it working with one of the above?

  • #5 / Oct 18, 2012 9:53am

    1) I added the “channel” parameter it still lists all categories (as expected).
    2) I added the “show” parameter, and it displays nothing at all on screen.
    http://www.gigant.co.uk/index-new.php/products/test

    {exp:channel:categories channel="products" show="13"}
     {category_name}
     {category_image}
    {/exp:channel:categories}

    3) The “channel_heading” tag isn’t any good for me, as I’m not in a specific Category page; rather a sub-category listing page, displaying all the sub-categories.

  • #6 / Oct 18, 2012 10:13am

    Robin Sowell

    13255 posts

    Real quick try two things to see what’s going on:

    {exp:channel:categories channel="products" show="13"}
     {category_name}
     {category_image}
    {if no_results}No cat 13{/if}
    {/exp:channel:categories}

    And in ‘Admin- System Prefs- Output and Debug’ turn on ‘Display Output Profiler?’.  Then look through the SQL that shows in the debug and find any that reference category id 13.  Paste back- let’s make sure the query is right.

  • #7 / Oct 18, 2012 11:28am

    There you go, run the page now and see what’s what.  😊
    http://www.gigant.co.uk/index-new.php/products/test

  • #8 / Oct 18, 2012 2:33pm

    Robin Sowell

    13255 posts

    Argh!  It is taunting me.  I get a blank white screen!  Something is odd- be on the lookout for an email.  Perhaps if I take a closer look I’ll spot what’s going on!

  • #9 / Oct 19, 2012 5:57am

    Oh that’s weird - looks like you can only see the debugging code if you’re logged in.
    Will reply to your other email now.  😊

  • #10 / Oct 19, 2012 11:29am

    Kurt Deutscher

    827 posts

    Any chance, that category that will not display, is a “child” category?

    https://support.ellislab.com/bugs/detail/17853

  • #11 / Oct 19, 2012 3:50pm

    Dan Decker

    7338 posts

    Hey Kurt!

    Thanks for the reminder. I thought that bug had been fixed, but now I see it’s a bit of discussion.

    Once Robin gets a look, we’ll have a solid answer for this.

    Thanks!

  • #12 / Oct 22, 2012 5:43am

    Yes that’ll be it.
    Apparently I can show the data for the parent categories at the same time, but not the child data on its own.

    {exp:channel:categories channel="products" show="2|637|13" style="nested"}
    {category_name}
    {/exp:channel:categories}

    Any ideas when this might be fixed guys?

  • #13 / Oct 22, 2012 12:07pm

    Kevin Smith

    4784 posts

    Hi all,

    From the comments in that bug report, it doesn’t look like that’s a feature that’s going to be added to the tag. Let me recommend an add-on that should help you achieve what you’re looking for. Have you given a look to GWcode Categories yet?

  • #14 / Oct 24, 2012 5:15am

    No I don’t think that will output the Category Name and Image for a single specific sub-category. Or am I wrong?
    I have found an alternative - slightly non-ideal method to achieve this for now.

    I hope Categories become a more significant element of EE, which will be looked at for a major upgrade in the future.
    Despite there being a quite a few add-ons which help, I think many of us developers are hoping for better built-in control and flexibility with Categories.  😊

    Keep up the good work.

  • #15 / Oct 25, 2012 10:44am

    Dan Decker

    7338 posts

    Hi IC360,

    Thank you for the feedback, we really do appreciate it!

    If you have time, we’d love to hear about the alternative method you’ve come up with.

    Is there anything else I can assist you with?

    Cheers,

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

ExpressionEngine News!

#eecms, #events, #releases