How to add adsense in between Articles on Phpbb Forums

Discussion in 'phpBB' started by jojojosonm, Sep 4, 2006.

  1. #1
    If you have a Phpbb Subsilver Forum( even phpbb2.0 Plus), Here is a Method to add adsense as first reply to your Threads. You may change the color to subsilver for Better Results.

    EDIT VIEWTOPIC.PHP

    In viewtopic.php in the main phpBB directory, at around line 826, you'll find:

    //
    // Okay, let's do the loop, yeah come on baby let's do the loop
    // and it goes like this ...
    //Right under that is the statement that begins the looping through the posts:

    for($i = 0; $i < $total_posts; $i++)
    {Under that I added...

    if ($i=="0") {
    $adblock = $adblocktext;
    } else {
    $adblock = "";
    }Up near the beginning of the file, I defined the new variable $adblocktext thusly:

    $adblocktext = <<<EOM
    <tr><td colspan=2 align=center>
    Insert your Google AdSense Code Here
    </td></tr>
    <tr><td class="spaceRow" colspan="2" height="1"><img
    src="templates/subSilver/images/spacer.gif"
    alt="" width="1" height="1" /></td>
    </tr>
    EOM;The table structure here is important. The first block puts in your Google AdSense code. The second block is a separator line.

    Now, scroll down to the line 1170'ish range of the file and you'll find a block of variable declarations that begins with:

    $template->assign_block_vars('postrow', array(
    'ROW_COLOR' => '#' . $row_color,
    'ROW_CLASS' => $row_class,In that block, on its own line, add:

    'AD_BLOCK' => $adblock,Save that file.

    EDIT VIEWTOPIC_BODY.TPL

    Now go into the templates directory, and into the subdirectory of the template you are using (i.e. subSilver). Open the file viewtopic_body.tpl for editing.

    Down around line 61, you'll find a line that says:

    <!-- END postrow -->Right above it, add the following text...

    {postrow.AD_BLOCK}Save the file, and you're done!

    Now your forums will insert whatever you wish after the first post. And yes, you can insert Javascript. I tried the following...

    $adblocktext = <<<EOM
    <tr><td colspan=2 align=center>
    Insert Google Code Here <P>
    <script language=javascript>
    document.write("hoobastank");
    </script>
    </td></tr>
    <tr><td class="spaceRow" colspan="2" height="1"><img
    src="templates/subSilver/images/spacer.gif" alt="" width="1"
    height="1" /></td>
    </tr>
    EOM;


    and it worked just fine.
     
    jojojosonm, Sep 4, 2006 IP
  2. Endurer

    Endurer Well-Known Member

    Messages:
    1,113
    Likes Received:
    84
    Best Answers:
    0
    Trophy Points:
    140
    #2
    Are you the author of this mod? If not, can you please mention the name of the author.
     
    Endurer, Sep 5, 2006 IP
  3. lordlisa

    lordlisa Peon

    Messages:
    58
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Thanks Man
    i will use this now on my forums
     
    lordlisa, Sep 5, 2006 IP