Info
- 4 posts
- 2 voices
- Started 5 years ago by Mirce
- Latest reply from ear1grey
- This topic is not resolved
Setting a different css class for the first topic
-
- Posted 5 years ago #
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. -
- Posted 5 years ago #
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";} -
- Posted 5 years ago #
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.
-
- Posted 5 years ago #
It doesn't have to know the difference. You set
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).$specialThe 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.
-
You must log in to post.