MyBB Community Forums
How to put ads per every 5 threads on forumdisplay? - Printable Version

+- MyBB Community Forums (https://community.mybb.com)
+-- Forum: 1.8 Support (https://community.mybb.com/forum-175.html)
+--- Forum: General Support (https://community.mybb.com/forum-176.html)
+--- Thread: How to put ads per every 5 threads on forumdisplay? (/thread-230565.html)



How to put ads per every 5 threads on forumdisplay? - online0227 - 2020-12-14

Hello, I am trying to put ads in forumdisplay per every 5 thread. I looked into forumdisplay file, there is a variable $threadcount in forumdisplay.php.
But this is called only once, and it doesn't count exact number of posts in current page. It just yields total number of threads in all pages.
So putting code like follow in forumdisplay_thread template didn't work using PHP and template conditional plugin:

<if $threadcount % 5 == 0 then>
<div style="text-align:center;">
{myadvertisements[zone_4]}
</div>
</if>

How do I solve this?
Thanks.

Solved. Just put
$threadcounter = 0;
before "if(!empty($threadcache) && is_array($threadcache))" in forumdisplay, then modify below

else
{
$bgcolor = alt_trow();
$threadcounter++;
echo "<script>console.log('Debug Objects: " . $threadcounter . "' );</script>";
}