Not signed in (Sign In)

Categories

Vanilla 1.1.4 is a product of Lussumo. More Information: Documentation, Community Support.

Help keep Vanilla free:
Welcome Guest!
Want to take part in these discussions? If you have an account, sign in now.
If you don't have an account, apply for one now.
  1.  # 1
    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.
    •  
      CommentAuthorWallPhone
    • CommentTimeJan 22nd 2007 edited
     # 2
    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: http://lussumo.com/community/discussion/4959/alter-first-comment/#Item_2

    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.
  2.  # 3
    thanks, wall! I will try this tonight.

    Any time frame, even rough, as to when your extension will be completed?
    •  
      CommentAuthorWallPhone
    • CommentTimeJan 22nd 2007
     # 4
    It will be a couple months. That code I posted is directly from it.
  3.  # 5
    Great stuff, wallphone.

    Lost last night....so going to try your code today.
    •  
      CommentAuthorWallPhone
    • CommentTimeJan 23rd 2007
     # 6
    I missed Lost!?!?! I hope the wife recorded it.
  4.  # 7
    LOL!!
    • CommentAuthornuclearw
    • CommentTimeJan 28th 2007
     # 8
    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 :)
    • CommentAuthorjoemad
    • CommentTimeMar 13th 2007
     # 9
    I tried it and screwed my comments up. Any help would be much appreciated...
    <?php
    /*
    * Copyright 2003 Mark O'Sullivan
    * This file is part of Vanilla.
    * Vanilla is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
    * Vanilla is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
    * You should have received a copy of the GNU General Public License along with Vanilla; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
    * The latest source code for Vanilla is available at www.lussumo.com
    * Contact Mark O'Sullivan at mark [at] lussumo [dot] com
    *
    * Description: Display, add, and manipulate discussion comments
    */

    include("appg/settings.php");
    $Configuration['SELF_URL'] = 'comments.php';
    include("appg/init_vanilla.php");

    // 1. DEFINE VARIABLES AND PROPERTIES SPECIFIC TO THIS PAGE

    // Ensure the user is allowed to view this page
    $Context->Session->Check($Context);

    // Instantiate data managers to be used in this page
    $DiscussionManager = $Context->ObjectFactory->NewContextObject($Context, "DiscussionManager");

    // Create the comment grid
    $DiscussionID = ForceIncomingInt("DiscussionID", 0);
    $CommentGrid = $Context->ObjectFactory->CreateControl($Context, "CommentGrid", $DiscussionManager, $DiscussionID);

    // Create the comment form
    if ($CommentGrid->ShowForm) {
    $CommentForm = $Context->ObjectFactory->CreateControl($Context, 'DiscussionForm');
    $CommentForm->Discussion = &$CommentGrid->Discussion;
    $CommentFoot = $Context->ObjectFactory->CreateControl($Context, 'Filler', 'comments_foot.php');
    }

    // Define properties of the page controls that are specific to this page
    $Head->BodyId = 'CommentsPage';
    $Menu->CurrentTab = "discussions";
    $Panel->CssClass = "CommentPanel";
    $Panel->BodyCssClass = "Comments";
    $Context->PageTitle = $CommentGrid->Discussion->Name;

    // 2. BUILD PAGE CONTROLS

    // Add discussion options to the panel
    if ($Context->Session->UserID > 0) {
    $Options = $Context->GetDefinition("Options");
    $Panel->AddList($Options, 5);
    $BookmarkText = $Context->GetDefinition($CommentGrid->Discussion->Bookmarked ? "UnbookmarkThisDiscussion" : "BookmarkThisDiscussion");
    $Panel->AddListItem($Options,
    $BookmarkText,
    "./",
    "",
    "id=\"SetBookmark\" onclick=\"SetBookmark('".$Configuration['WEB_ROOT']."ajax/switch.php', ".$CommentGrid->Discussion->Bookmarked.", '".$CommentGrid->Discussion->DiscussionID."', '".$Context->GetDefinition("BookmarkText")."', '".$Context->GetDefinition("UnbookmarkThisDiscussion")."'); ".$Context->PassThruVars['SetBookmarkOnClick']."return false;\"");

    if ($Context->Session->User->Permission("PERMISSION_HIDE_DISCUSSIONS")) {
    $HideText = $Context->GetDefinition(($CommentGrid->Discussion->Active?"Hide":"Unhide")."ThisDiscussion");
    $Panel->AddListItem($Options,
    $HideText,
    "./",
    "",
    "id=\"HideDiscussion\" onclick=\"if (confirm('".$Context->GetDefinition($CommentGrid->Discussion->Active?"ConfirmHideDiscussion":"ConfirmUnhideDiscussion")."')) DiscussionSwitch('".$CommentGrid->Context->Configuration['WEB_ROOT']."ajax/switch.php', 'Active', '".$CommentGrid->Discussion->DiscussionID."', '".FlipBool($CommentGrid->Discussion->Active)."', 'HideDiscussion'); return false;\"");
    }
    if ($Context->Session->User->Permission("PERMISSION_CLOSE_DISCUSSIONS")) {
    $CloseText = $Context->GetDefinition(($CommentGrid->Discussion->Closed?"ReOpen":"Close")."ThisDiscussion");
    $Panel->AddListItem($Options,
    $CloseText,
    "./",
    "",
    "id=\"CloseDiscussion\" onclick=\"if (confirm('".$Context->GetDefinition($CommentGrid->Discussion->Closed?"ConfirmReopenDiscussion":"ConfirmCloseDiscussion")."')) DiscussionSwitch('".$CommentGrid->Context->Configuration['WEB_ROOT']."ajax/switch.php', 'Closed', '".$CommentGrid->Discussion->DiscussionID."', '".FlipBool($CommentGrid->Discussion->Closed)."', 'CloseDiscussion'); return false;\"");
    }
    if ($Context->Session->User->Permission("PERMISSION_STICK_DISCUSSIONS")) {
    $StickyText = $Context->GetDefinition("MakeThisDiscussion".($CommentGrid->Discussion->Sticky?"Unsticky":"Sticky"));
    $Panel->AddListItem($Options,
    $StickyText,
    "./",
    "",
    "id=\"StickDiscussion\" onclick=\"if (confirm('".$Context->GetDefinition($CommentGrid->Discussion->Sticky?"ConfirmUnsticky":"ConfirmSticky")."')) DiscussionSwitch('".$CommentGrid->Context->Configuration['WEB_ROOT']."ajax/switch.php', 'Sticky', '".$CommentGrid->Discussion->DiscussionID."', '".FlipBool($CommentGrid->Discussion->Sticky)."', 'StickDiscussion'); return false;\"");
    }
    if ($Context->Session->User->Permission("PERMISSION_SINK_DISCUSSIONS")) {
    $SinkText = $Context->GetDefinition("MakeThisDiscussion".($CommentGrid->Discussion->Sink?"UnSink":"Sink"));
    $Panel->AddListItem($Options,
    $SinkText,
    "./",
    "",
    "id=\"SinkDiscussion\" onclick=\"if (confirm('".$Context->GetDefinition($CommentGrid->Discussion->Sink?"ConfirmUnSink":"ConfirmSink")."')) DiscussionSwitch('".$CommentGrid->Context->Configuration['WEB_ROOT']."ajax/switch.php', 'Sink', '".$CommentGrid->Discussion->DiscussionID."', '".FlipBool($CommentGrid->Discussion->Sink)."', 'SinkDiscussion'); return false;\"");
    }
    }

    // Create the comment footer
    $CommentFoot = $Context->ObjectFactory->CreateControl($Context, "CommentFoot");

    // 3. ADD CONTROLS TO THE PAGE

    $Page->AddRenderControl($Head, $Configuration["CONTROL_POSITION_HEAD"]);
    $Page->AddRenderControl($Menu, $Configuration["CONTROL_POSITION_MENU"]);
    $Page->AddRenderControl($Panel, $Configuration["CONTROL_POSITION_PANEL"]);
    $Page->AddRenderControl($NoticeCollector, $Configuration['CONTROL_POSITION_NOTICES']);
    $Page->AddRenderControl($CommentGrid, $Configuration["CONTROL_POSITION_BODY_ITEM"]);
    if ($CommentGrid->ShowForm) {
    $Page->AddRenderControl($CommentForm, $Configuration["CONTROL_POSITION_BODY_ITEM"] + 10);
    $Page->AddRenderControl($CommentFoot, $Configuration["CONTROL_POSITION_BODY_ITEM"] + 11);
    }
    $Page->AddRenderControl($Foot, $Configuration["CONTROL_POSITION_FOOT"]);
    $Page->AddRenderControl($PageEnd, $Configuration["CONTROL_POSITION_PAGE_END"]);

    // 4. FIRE PAGE EVENTS
    $Page->FireEvents();

    // 5. GOOGLE
    if ($Comment->Deleted) $CommentClass .= ' Hidden';
    if ($Alternate) $CommentClass .= ' Alternate';
    $CommentClass = trim($CommentClass);
    //Begin adSense Code Insertion
    if ( $RowNumber == 4 || $RowNumber == 10) {
    $CommentList .= '
    <!--
    google_ad_client = "pub-6403838485942358";
    google_ad_width = 728;
    google_ad_height = 90;
    google_ad_format = "728x90_as";
    google_ad_type = "text";
    google_ad_channel = "";

    //-->


    ';
    }
    //End Adsense Code Insertion


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

    ?>
    •  
      CommentAuthorWallPhone
    • CommentTimeMar 13th 2007
     # 10
    I believe that should be the comments.php file in the themes folder--not the root.
    • CommentAuthorEvic
    • CommentTimeMar 13th 2007
     # 11
    @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.
    • CommentAuthoriternity
    • CommentTimeMar 13th 2007
     # 12
    Is this extension available? :)
    •  
      CommentAuthor[-Stash-]
    • CommentTimeMar 13th 2007
     # 13
    @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 :)
Add your comments
    Username Password
  • Format comments as