PDA

View Full Version : Conditional for after first post of a thread


skor
12-10-2010, 05:06 PM
I am trying to put some text only after the first post in a thread for a specific forum . I've tried...

<if condition="$forum['forumid'] == 24 AND !$GLOBALS['FIRSTPOSTID']">text here</if>

the only issue I am having is that it's appearing after the first post on every page for a thread that has multiple pages.

is there a conditional that would include it only after the first post of the whole thread so that it wouldn't show on the 2nd page?

thank you

calorie
12-10-2010, 05:08 PM
How about including page number as part of the condition?

skor
12-10-2010, 05:17 PM
Hi thank you for the reply.

I tried...

<if condition="$forum['forumid'] == 24 AND !$GLOBALS['FIRSTPOSTID'] AND $pagenumber == 1"> but that didn't seem to work. Nothing showed up on any of the pages.

wasn't sure if it's because I am not allowed to use multiple AND's?

kh99
12-10-2010, 05:30 PM
I just looked at that because someone asked something similar a couple days ago. If you are putting your "if" condition in a postbit template, I don't think the page number is available, but you could use a plugin to make it available if you wanted.

skor
12-10-2010, 05:36 PM
I found this

https://vborg.vbsupport.ru/showthread.php?t=208945&highlight=$pagenumber

but does anyone know if that solution would cause any sort of additional db queries?

Do you know which plugin that is?

kh99
12-10-2010, 05:38 PM
That's the same kind of thing I was talking about except editing the file instead of a plugin.

No, it won't add any db queries.

ETA: postbit_display_complete should work - of course you'd have to add a separate "global" line instead of adding to the existing one.

skor
12-10-2010, 05:55 PM
ETA: postbit_display_complete should work - of course you'd have to add a separate "global" line instead of adding to the existing one.

Thank you. I'm kind of lost on what you mean by this?

Is postbit_display_complete a template? Couldn't find it in the templates or in the php files?

And would I add something like

global $pagenumber; to the top of this file?

Sorry for my igorance...pretty much know how to search for things but not much else...

kh99
12-10-2010, 05:57 PM
No, I'm sorry I assumed you would know what I meant.

postbit_display_complete is a hook location, so you could create a new plugin and select that hook location and for the code use "global $pagenumber;" (you need a title so you'll remember what it is, and you need to select the "Yes" radio button on the bottom to activate it, but the other fields don't matter).

You could also edit the class_post.php file like that post suggests if you want, but I think it's easier to manage upgrades if you avoid editing your php files.

skor
12-10-2010, 05:58 PM
Thank you very much! :)

calorie
12-10-2010, 06:02 PM
Are you editing the postbit template? How about something like this at the end of the postbit template instead?

<if condition="$post[postcount] == 1">
<div style="padding-top:5px">
text here
</div>
</if>

skor
12-10-2010, 09:58 PM
Are you editing the postbit template? How about something like this at the end of the postbit template instead?

<if condition="$post[postcount] == 1">
<div style="padding-top:5px">
text here
</div>
</if>


Thank you for that! I ended up using

<if condition="$forum['forumid'] == 24 AND $post[postcount] == 1">

and it worked great!

Appreciate both of your help on teaching me something new!

kh99
12-10-2010, 10:06 PM
Oops - That's pretty obvious, I don't know why I didn't think of that since the post numbers are displayed right in the post... :o