MyBB Community Forums

Full Version: Check posts in the page conditional?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
Please I need a conditional that will show code only when the page has 10 posts and the 10th post ain't last?
Thanks man but I want the conditional to first check if the page contains 10 posts and if it does then next check if the 10th post is not last only then show code but hey thanks for trying to help Smile
<if $postcounter == 10 && $thread['lastpost'] != $post['dateline'] then>
10th post not last...
</if>

DrXotick seems to be right - if the post counter is not ten it won't show, if it is the last post it wont show. Have you tried that code?
@Leefish baby thanks very much for your reply. Please let me explain Google only allows 3 ads per page and I want the add to show in 1st, 2nd and 3th post so it makes 3 posts per page that has 10 posts. Now the problem is I have a code that adds Adsense to last post so it will result in 4 ads per page!

I am looking for a way to show ad in the 3th post only if the page has 10 posts and the last post is not last only then show ad in 3th post! Crazy I know?

I don't know maybe I can do this:

<if $postcounter == 10 && $thread['lastpost'] != $post['dateline'] then>
<if $postcounter == 3 && $thread['lastpost'] != $post['dateline'] then>
3rd post not last...
</if>
</if>
First, dont call me baby Smile , lee is fine.

So what you want is a way to count how many posts there are on the page? No idea.
Sorry lee! I was juts trying to be friendly with you but it's cool.

Could you please make this work?

<if (($postcounter - 3) % $mybb->settings['postsperpage'] == 0)  && (($postcounter - 10) % $mybb->settings['postsperpage'] == 0) then>
3rd post adsense
</if>
Both codes you posted have no sense - they always result in false and the text would never be output.

You can try:
<if ($postcounter - 3) % $mybb->settings['postsperpage'] == 0 && $thread['replies'] - $page * $mybb->settings['postsperpage'] < $mybb->settings['postsperpage'] then>
Output ad in 3rd post on each page only if post limit on one page wasn't reached (by default 10).
</if>
Didn't test but should work.
D666 my man thanks very much for your support I have just tested it and I am very sorry but it's not working! It shows after the 1 page and despite the fact that page only has 6 posts. Please if you think it could be done help me?
I don't even understand what you want then... Can you elaborate or show it on a screen?

This is how it works:
1st conditional before && checks if the post is 3rd on any page
2nd checks the amount of replies on page, it is true only if there are less posts than $mybb->settings['postsperpage'] on that page.

For example for $mybb->settings['postsperpage'] = 10 and $thread['replies'] = 17 (number of replies in thread):
Page 1: 1,2,3,4,5,6,7,8,9,10 Page 2: 11,12,13,14,15,16,17 - only 13 will be true and ad will show there (tested and works). So it won't show in 3rd post as you said when you have ad in last (10th) post on that page...
Pages: 1 2