MyBB Community Forums

Full Version: template conditionals, how to determine last post on the page?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I'd like to put an ad inside the last post of a thread on a page.

I'm using this:
<if ($postcounter - 1) % $mybb->settings['postsperpage'] == "0" then>

To determine first post, but want to put an ad in the last post of each page.
template conditional is not required for placing advt after the last post
in the showthread template, you can put required code at the bottom of code like below
<div id="posts">
	{$posts} 
</div>
Thanks .m.,

I want to put it actually inside the post. Not outside. I'm using postbit now to place it in the first post, but need theconditional statement to place an ad in the last post if there's 4 or more posts on a page of a thread. eg, [if number of posts on page > 3 then advertisement in last post]
<if ($postcounter - $mybb->settings['postsperpage']) % $mybb->settings['postsperpage'] == 0 || $thread['lastpost'] == $post['dateline'] then>
xxx
</if>
for last post on each page, no matter which post is that on last page.

<if ($postcounter - $mybb->settings['postsperpage']) % $mybb->settings['postsperpage'] == 0 || ($thread['lastpost'] == $post['dateline'] && ($postcounter - 3) % $mybb->settings['postsperpage'] > 0) then>
xxx
</if>
for last post on each page except last and last post on last page if it's higher than 3 on that page.
<if $thread['replyto'] == 0 then>
	// do something if first post
</if>

<if $thread['lastpost'] == $post['dateline'] then>
	// do something if last post
</if>

<if $postcounter == $mybb->settings['postsperpage']*($page-1)+1 then>
	// do something if first post in the current page
</if>

<if $postcounter == $mybb->settings['postsperpage']*$page then>
	// do something if last post in the current page
</if>

<if $postcounter == n then>
	// do something if nth post
</if>
Okay. This is excellent. Thanks Destroy666 and thanks Shade for the extra info.

I ended up using

<if ($postcounter - $mybb->settings['postsperpage']) % $mybb->settings['postsperpage'] == 0 || ($thread['lastpost'] == $post['dateline'] && ($postcounter - 3) % $mybb->settings['postsperpage'] > 0) then>
xxx
</if>

Works butter.