Welcome IP: 67.215.231.210

Include Adsense between PHPBB article posts

Send this article to a friend Send this article to a friend

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:

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

XML:
  1. //
  2. // Okay, let’s do the loop, yeah come on baby let’s do the loop
  3. // and it goes like this …
  4. //
  5. for($i = 0; $i <$total_posts; $i++)
  6. {

Directly under add the following:

XML:
  1. if ($i=="0") {
  2. $adblock = $adblocktext;
  3. } else {
  4. $adblock = "";
  5. }

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

XML:
  1. $adblocktext = <<<EOM
  2. <tr><td colspan=2 align=center>
  3. Replace this text with code
  4. </td></tr>
  5. <tr><td class="spaceRow" colspan="2" height="1"><img
  6. src="templates/subSilver/images/spacer.gif"
  7. alt="" width="1" height="1" /></td>
  8. </tr>
  9. EOM;

Now, find the following:

XML:
  1. $template->assign_block_vars('postrow', array(

Directly under this, on its own line, add:

XML:
  1. 'AD_BLOCK' => $adblock,

* Save the modified viewtopic.php file.

Go to your templates directory, and to the subdirectory of the template you are using (EX: SubSilver). Download and open viewtopic_body.tpl.

find the following:

XML:
  1. <!-- END postrow -->

Directly above it, add the following:

XML:
  1. {postrow.AD_BLOCK}

* Save the modified viewtopic_body.tpl file.

To add your Google Adsense Code:

Open viewtopic.php and find the line: Replace this text with code

Replace that line with your google adsense code, save, and your forum will now contain an adsense ad after every first post.


                            

If you find this information useful, feel free to express your support via a quick PayPal Donation: