Ramui webblog Free Blog Script

Adding adsense code on PHPBB3.x forum

To add adsense code on your PHPBB3.x forum you have to edit template file. For detail how to edit template file within your Admin control panel please read http://ramui.com/phpbb/add-sidebar-in-phpbb3-template.html.

Adding adsense code after each post:

  1. Login to your adsense account and create an adsense unit of suitable size with background color = border color = forum post background color.
  2. Login to your forum Administration Control Panel.
  3. Click on the tab "Styles".
  4. At the left menu click on the link "Templates" under the category "Style components". A list of all installed templates will appear.
  5. Click on the "Edit" link of the template which you're using for your board.
  6. A combo box listing all template files will appear. Select the file "viewtopic_body.html" at the end of the list.
  7. Find string
    <div class="postbody">{postrow.MESSAGE}</div>
  8. Replace that string by the followings.
Code | Download
<div class="postbody"> {postrow.MESSAGE}
<table style="width: 100%; margin: 10px 0 ;"><tr><td style="text-align: center;">
<!--your Adsense code here -->
</td></tr></table>
</div>

Replace the text "<!--your Adsense code here -->" with your adsense code. Please do not forget to save the changes you have made.

AdSense Ad only the first or the original post on phpBB3.x

If you like to add adsense code after first or original post then you have to enable PHP code in your template file.
To do this,

  1. Login to your admin control panel.
  2. Under General tab click on the link security setting at the bottom of the vertical menu.
  3. Now enable the option Allow php in templates:.
  4. Click submit button to save the change.

Now open file "viewtopic_body.html." Find string
<div class="postbody">{postrow.MESSAGE}</div>

Replace that string by the followings.

Code | Download
<div class="postbody">{postrow.MESSAGE}
<!-- PHP -->
static $adsense=0;
$adsense++;
$adsense_max=1; //no. of adsense block.
if($adsense<=$adsense_max){
<!-- ENDPHP -->
<table style="width:100%; margin:10px 0;"><tr><td style="text-align:center;">
<!%u2014your Adsense code here -->
</td></tr></table>
<!-- PHP -->}<!-- ENDPHP -->
</div>

Please do not forget to save the changes you have made.

Comment