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 add-on for Vanilla 1

edited October 2006 in Vanilla 1.0 Help
Hello, I wanted to put some google ads on my forum. but the only extention available is only available for Vanilla 0.9.2, and i have vinilla 1 so how can can i put the ads on their without an add on. I woul appreciate you help thank you
«13

Comments

  • agreed... can we get a vanilla 1 version?
  • I made some changes to the code I had for Vanilla 0.9.2, some instructions.

    1. Create a directory in your extensions directory. I created one called "Adsense"

    2. Create a file called "default.php" inside the new directory.

    3. Include the following code:

    ?php /* Extension Name: Google Adsense Extension Url: www.lussumo.com Description: Adds Google Adsense Version: 0.1 Author: Alexis Bellido Author Url: http://www.teleworkpeople.com */ if(in_array($Context->SelfUrl, array("index.php", "categories.php", "comments.php", "search.php", "post.php", "account.php" , "settings.php"))){ $adcode = <<< ENDCODE <div id="adsense-vertical"> <script type="text/javascript"><!-- google_ad_client = "pub-8679467187142369"; google_ad_width = 120; google_ad_height = 240; google_ad_format = "120x240_as"; google_ad_type = "text"; google_color_border = "B44551"; google_color_bg = "FFFFFF"; google_color_link = "B44551"; google_color_url = "B44551"; google_color_text = "B44551"; //--></script> <script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> </script> </div> ENDCODE; $Panel->AddString($adcode,false); } ?>

    4. Replace pub-XXXXXXXXX with your Adsense publisher code, you can replace the whole code of Google in fact. I'm just putting some generic one.

    Of course the code can be improved and Adsense put in another locations but this is working for me and I hope it can give you an idea of what to do.

    Actually it's the same code I used in 0.9.2.

    Regards!
  • Why don't you add it to the Add-Ons directory?
  • Alexis,

    How would you place it elsewhere on a Vanilla forum? I've seen the add-on for placing it in the side panel, but not above the discussions or categories listing page. Have any ideas?
  • edited July 2006
    cool
  • Is there an adsense extension that places the horizontal ad above the discussions ? I know ive seen on some vanilla forums. Is it available here somehwere ?

    Thanks
  • at least i would stop supporting google (also even with such add helpers). not only because they own your ass one day .... irreversible.
  • Does anyone have any luck with Google AdSense on their Vanilla installation? I'm considering it atm...
  • I've just put it on and it works fine using sidepanel 1.0, just create the code on the google site and insert it to the extension file and you're away!
  • Blize, i used it for a month or so.........but one of my regulars said that on his work pc, it pushed the main threads/discussion page down th epage.........he had to scroll down to find the threads/chat I took it off. I never saw a problem...and no one else reported a prob. But that one regular had that issue on his work pc (tho at home, he said it was fine)
  • I see, thanks. I'm just trying to work out whether or not it's worth it. On some sites they're quite seamless but on Vanilla I imagine it'd stick out a bit too much, I'm also not sure whether people would actually click it or not ;o
  • Okay then, due to a change of circumstances I've decided to go ahead with it and try and get a bit of revenue back towards the hosting costs, is there anyway to display the adverts, with a small caption above saying "Please login to remove these adverts" and then of course the whole thing dissapearing if a user is logged in? Thanks
  • edited August 2006
    I believe checking if someone is signed on is as simple as if ($Context->Session->UserID == 0) { // Rest of addon code goes here. Code only runs if visitor is not signed in. }
  • Many thanks for that, and how would one go about placing it above the comments/discussions bit? Where the announcement goes basically, but on the comments pages too ;o Ty!
  • edited August 2006
    This may not be the best way, (might be better to use a delegate if this becomes styled wierd) but try:$NoticeCollector->AddNotice($adcode); instead of $Panel->AddString($adcode);
  • Sorry to be a pain, but how exactly do I place the adwords onto the page then? Thanks
  • edited October 2006
    Use all the same code as alexis' code above, but replace the last $Panel->Addstring bit to $NoticeCollector->AddNotice

    Otherwise, here is an example using a delegate:

    <?php /* Extension Name: Adsense for Guests Extension Url: www.lussumo.com/Add-ons/ Description: Adds Google Adsense at the top of the discussions Version: 0.2 Author: WallPhone, based on existing code by Alexis Bellido Author Url: http://wallphone.com */ function InjectAdsense() { echo '<div align="center"> <script type="text/javascript"><!-- google_ad_client = "pub-5163550033929978"; google_ad_width = 728; google_ad_height = 90; google_ad_format = "728x90_as"; google_ad_type = "text_image"; google_ad_channel ="3348340772"; google_color_border = "FFFFFF"; google_color_bg = "EEEEEE"; google_color_link = "008000"; google_color_text = "000000"; google_color_url = "336600"; //--></script> <script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> </script></div>'; } if ( ($Context->Session->UserID == 0) && (in_array($Context->SelfUrl, array("index.php", "categories.php", "comments.php", "search.php", "post.php", "account.php", "settings.php"))) ){ $NoticeCollector->AddNotice('Please <a href="'.GetUrl($Configuration, 'people.php'). '">sign in</a> or <a href="'. GetUrl($Configuration, 'people.php', '', '', '', '', 'PostBackAction=ApplyForm'). '">apply for membership</a> to remove the ads'); $Context->AddToDelegate('NoticeCollector', 'PostRender', 'InjectAdsense'); } ?>

    EDIT: Fixed typos, tested code, centered ad-block, improved readability, and removed a bug.
  • blizeHblizeH ✭✭
    edited August 2006
    Absolute legend! Worked a treat, many thanks! Now I just need to find my Google Adsense details, haha.
  • edited September 2006
    I made one more chage since you implemented it: centered the ad block.

    Oh, and change your google_ad_client = "pub-5163550033929978";! That one is mine... but don't hurry, I appreciate the exposure!

    Mark: Found a bug with the notice running into the top of the search page in both IE and Firefox:
    image
  • Huge thanks mate, you're a star!
This discussion has been closed.