Include Adsense between PHPBB article posts

This tutorial will show you how to place google adsense ads between articles in your phpbb forum. When finished, Your forum will automatically show one ad after the first post within each article and continue on any additional pages stemming from that article.

Adding Adsense between PHPBB article posts:

  1. In your PHPBB forum root directory, locate, download and open viewtopic.php, and find the following:

    for($i = 0; $i <$total_posts; $i++)
    {

  2. Directly under add the following:

    if ($i=="0") {
    $adblock = $adblocktext;
    } else {
    $adblock = "";
    }

  3. At the beginning of the viewtopic.php file, Add the following:

    $adblocktext = <<
    Replace this text with code
    src="templates/subSilver/images/spacer.webp"
    alt="" width="1" height="1" />
    EOM;

  4. Now, find the following:

    $template->assign_block_vars('postrow', array(

  5. Directly under this, on its own line, add:

    'AD_BLOCK' => $adblock,

  6. Save the modified viewtopic.php file.
  7. Go to your templates directory, and to the subdirectory of the template you are using (EX: SubSilver). Download and open viewtopic_body.tpl.
  8. find the following:

    <!-- END postrow -->

  9. Directly above it, add the following:

    {postrow.AD_BLOCK}

  10. Save the modified viewtopic_body.tpl file.

Finally, to add your Google Adsense Code:

  1. Open viewtopic.php and find the line: Replace this text with code and replace that line with your google adsense code
  2. Save viewtopic.php and go view your forum. It will now contain an adsense ad after every first post