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.

Multiple categories, just one image

June 09, 2008 4:22am

Subscribe [2]
  • #1 / Jun 09, 2008 4:22am

    RichardC

    40 posts

    Is there a good way of just displaying one category image for a post with multiple categories assigned to it? I’ve been poking at it for much of the evening, which almost guarantees I’ve missed something really obvious, but…

  • #2 / Jun 10, 2008 4:02am

    RichardC

    40 posts

    Anyone?

  • #3 / Jun 10, 2008 4:18am

    gridonic

    231 posts

    Hi

    Should be pretty easy and straightforward, haven’t tested this but as {categories} does not seem to have a {count} variable, you could use PHP

    <?php $count = 0; ?>
    {categories}
    
    <?php if ($count++ < 1) { ?>
    
    {category_image}
    
    <?php } ?>
    
    {category_name}
    
    {/categories}

    or something similar. Haven’t tested this, just wrote it down here.

  • #4 / Jun 10, 2008 5:17am

    Ingmar

    29245 posts

    And if that does still not work, there’s always raw SQL queries as solution to almost any db related problem.

  • #5 / Jun 10, 2008 8:35am

    RichardC

    40 posts

    Erk. I fear queries. But thanks, I’ll give that one a try.

  • #6 / Jun 10, 2008 8:42am

    Ingmar

    29245 posts

    There seems to be a working one in that paralled thread.

  • #7 / Jun 10, 2008 10:20am

    Ingmar

    29245 posts

    On a final note, have you tried this?

    {categories limit="1"}
    {category_image}
    {/categories}
  • #8 / Jun 10, 2008 1:08pm

    RichardC

    40 posts

    Gah! What did I say about missing something incredibly obvious? That’s sorted it - thanks! 😉

  • #9 / Jun 10, 2008 1:19pm

    Ingmar

    29245 posts

    Don’t feel too bad, please: I get paid to know such things and initially missed it as well… 😊

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

ExpressionEngine News!

#eecms, #events, #releases