MyBB Community Forums

Full Version: How to put ads per every 5 threads on forumdisplay?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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>";
}