Vanilla 1 is no longer supported or maintained. If you need a copy, you can get it here.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.

google adsense extension

edited March 2007 in Vanilla 1.0 Help
I'd love to see a google adsense extension. i.e. one that allows you to set a default figure for how often you want the adsense adverts to appear on your discussion page. I have seen this type of thing in other forum software, where say after every 5 posts on a thread/page, is a google adsense ad.


  • Options
    edited January 2007
    I'm planning one out as we speak. Manages rotation, ad managment by role, etc.

    don't hold your breath though, its hardly near finished.

    In the meantime, you can get by with this:

    Right now it puts code at the first and last post. To get some in the middle, change that if block in the center to something like this:if ( 1 == $RowNumber % 5 ) { $Comment->Body .= $CommentGrid->Context->GetDefinition('AfterFirstPostCode'); }

    Adsense has a limit of the number of ads per page, so you might want to check up on that.
  • Options
    thanks, wall! I will try this tonight. Any time frame, even rough, as to when your extension will be completed?
  • Options
    It will be a couple months. That code I posted is directly from it.
  • Options
    Great stuff, wallphone. Lost last going to try your code today.
  • Options
    I missed Lost!?!?! I hope the wife recorded it.
  • Options
  • Options
    Hey guys, just remember the AdSense TOS says no more than 3 standard ad units per page. :)

    1 Link Unit on the same page is acceptable, I would hate to see people get kicked out of the adsense program for this.

    Here's my method:
    Edit comments.php (code here is before and after the ad code) Just paste your full code in between the and .
    This will display the ad blocks at set comment intervals. (in this case #4 and #10)

    if ($Comment->Deleted) $CommentClass .= ' Hidden';
    if ($Alternate) $CommentClass .= ' Alternate';
    $CommentClass = trim($CommentClass);
    //Begin adSense Code Insertion
    if ( $RowNumber == 4 || $RowNumber == 10) {
    $CommentList .= '

    //End Adsense Code Insertion

    $CommentList .= 'CommentID.'"'.($CommentClass == ''?'':' class="'.$CommentClass.'"').'>

    I also added it at the bottom of the "menu.php" theme file, in the text after the

    echo '

    hope this helps someone :)
  • Options
    joemadjoemad New
    edited November 2008
  • Options
    I believe that should be the comments.php file in the themes folder--not the root.
  • Options
    @nuclearw Google's scripts limit you to 3 units per page, so technically you could run your AdSense code within the comment loop (display an ad block after every comment) and only 3 units would display.
  • Options
    Is this extension available? :)
  • Options
    @nuclearw and joemad, I find both your code examples really hard to read (Wallphone isn't as lazy as me), if you pop some <code></code> tags around your code snippets and select the "Html" comment formatter (radio button just above the "Add you comments" button) then it makes it a lot easier to read. Thanks :)
This discussion has been closed.