Skip to:
Content
Pages
Categories
Search
Top
Bottom

Setting a different css class for the first topic

  • Is there a way to set up a new css class for the first post in a topic? I am thinking at something like;

    if post_id = 1

    echo “some class”

    I am a PHP newbye and I am having problems implementing this…

    Thanx.

Viewing 3 replies - 1 through 3 (of 3 total)
  • A lazy short circuit solution which makes the first displayed entry in a loop appear different:

    $special="specialClass normalClass";

    for {

      echo ... class="$special" ...

      $special="normalClass";

    }

    Sounds difficult to set up:)

    I understand that I create a variable but how do I make it make the difference between the posts.

    I found a bb_is_first and I am thinking in using this one somehow.

    It doesn’t have to know the difference. You set

    $special

    to be a special class before the loop, then the last thing you do in the loop is set

    $special

    to be something else. So the first time round the loop

    $special

    has it’s original value, then at the end of the first loop it’s value is changed (so it’s no longer the initial value).

    The fact that the value is repeatedly reset to the other value is irrelevant (there is overhead in this, but it’s comparable to calling a function each time round the loop to check for “is this the first item” and it has the advantage that it’s not API specific.

Viewing 3 replies - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.
Skip to toolbar