View Full Version : Detecting if it is the first post in a 'showthread' page
KiD0M4N
04-26-2008, 09:39 PM
Hi,
As the title says, I want to show something in the first post in a page (showthread) but not in the consecutive posts. Is there anyways I can detect this from within a template?
I hope I am asking in the right place.
Regards,
Karan
Lynne
04-26-2008, 10:39 PM
<if condition="$post['postid']==$thread['firstpostid']">
Stuff for first post only here
</if>
I think that will work.
KiD0M4N
04-26-2008, 10:56 PM
Ah thanks for the reply :) Gonna try right away :)
Sweet! Works like a charm. Thanks sir.
KiD0M4N
04-28-2008, 11:23 PM
<if condition="$post['postid']==$thread['firstpostid']">
Stuff for first post only here
</if>
I think that will work.
I think I jumped the happiness gun a bit too early.
This code is perfect for detecting if the current post is the first post even in a thread.
What I was wanting to achieve is to detected (yes/no) if the current post is the first post of a thread in that page.
I am sure the answer is simple, but i am not sure of where to look.
Looking forward to reply.
Karan
Lynne
04-28-2008, 11:50 PM
That is more complicated. You basically need to get the variable for the postnumber (I'll call it $postnum) and the number of posts allowed on a page (there is a default, but don't forget the user can override that - I'll call this $pageposts) and then divide one by the other and if the remainder is 1 then it is the first post.
Say it is post 3, the user allows 15 posts to a page, so 3 / 15 is 0 with a remainder of 3 - so not the first post. Say it is post 46 and the user allows 15 posts to a page, so 46/15 is 3 with a remainder of 1, so it is the first post.
This was actually all outlined in another thread and they may have actually come up with the code, but I don't have time to search for it. It's in the Community Discussions. Maybe search for "remainder" or something similar.
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.