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.

Advert addon

edited July 2006 in Vanilla 1.0 Help
hey can someone make a quick addon, i mean really quick that will post an advert after the first post in a thread?

Would be most grateful
Thanks, Immersion
«13

Comments

  • Immersion, I've created an add-on where it posts before the advert at the top of the body section on all sections. If you find a way to add it after the first post, I'd like to know so I can add it to my extension.
  • well may i please have your addon for your advert thing?
  • Okay, here it is below. Just replace your ad code with where I have mine echo'd. I put in /extensions/AdsenseCode/ and went into the extensions and it worked perfectly for me. <?php /* Extension Name: Google Adsense Extension Url: http://lussumo.com/docs/ Description: Adds Google Ads to the top of the main body. Version: 1.0 Author: JP Mitchell Author Url: http://www.ushomestoday.com/ */ if (in_array($Context->SelfUrl, array("index.php", "account.php", "categories.php", "comments.php", "post.php", "search.php", "settings.php"))) { class AdsenseCode extends Control { function AdsenseCode(&$Context) { $this->Name = "AdsenseCode"; $this->Control($Context); } function Render() { echo '<div class="Google_Ads"> <br> <center> <script type="text/javascript"><!-- google_ad_client = "pub-8674095945218999"; google_ad_width = 468; google_ad_height = 60; google_ad_format = "468x60_as"; google_ad_type = "text"; google_ad_channel ="5422124716"; google_color_border = "FFFFFF"; google_color_bg = "FFFFFF"; google_color_link = "0000FF"; google_color_text = "000000"; google_color_url = "000000"; //--></script> <script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> </script> </center> </div>'; } } $AdsenseCode = new AdsenseCode($Context); $Page->AddRenderControl($AdsenseCode, $Configuration["CONTROL_POSITION_BODY_ITEM"]-1); } ?>
  • YOu are a star, jpmitchell7!!! Worked a treat! Thanks!!!
  • edited July 2006
    Wonderful! I'm looking to improve on by adding an javascript adcode right above the "Add Your Comments" part of a discussion, but I haven't figured that out yet. I have my Vanilla tweaked that way, but not through an extension.
  • That would be a cool extension! My favorite idea would be for an extension that would add the google adsense script after x number of posts in the thread...........for example, after every 5 posts.
  • I'll try to look into that when I have time. I'm kinda new to PHP, but Mark and others were very helpful to my first attempt at this one.
  • you have done sterling work for being 'kinda new to php' :) I can tweak, but not to the level you did in making the above extension. This is such a great community - and to think that I only found it 3 weeks ago by chance after a person i know in another forum happened to mention it.
  • im trying to find out how to do it after x posts. I see the only way to do it is to make an extension that when countcomments in the discussion table reaches x the advert is posted. However i thought about making it so a new user was made called Ad Bot or something and then make an extension running of post.php that once a new thread is made it will post the advert from the Ad Bot. Then maybe a page in settings tab that showed controls over ad bot. However this second way would only work after first post if at all.
  • mark would using
    <?php function GetRowNumber(&$CommentGrid) { $RowNumber = $CommentGrid->DelegateParameters['RowNumber']; } ?>
    work to find out if it is the first post. Then you could do
    $x = 1; if ($RowNumber = $x) { echo 'hello'; }

    Well that being the principle of it not the actual code :P
  • Great idea! You have a much more logical brain than me, Immersion. I read a vbulletin board that has google adsense posted after x number of posts - and they have it really well incorporated into the threads page. eg http://www.emigratenz.org/forum/showthread.php?t=7056
  • PS - just after noticing that the url I posted above is clickable - hmmmm.....on my vanilla board, i have to cut and paste any url.......what am i doing wrong i wonder.
  • mm vbulliten just has a condition for their thing to work in their templating system, theree is <if:condition $postcount= 3. something. Its along those lines, im now looking at the ipb one for some ideas.
  • edited July 2006
    @strawberries: http://lussumo.com/addons/?PostBackAction=AddOn&AddOnID=8
  • i whisper would have been more appropriate :P
  • edited July 2006
    I didn't whisper so that everyone could see that the problem had been solved.
  • thanks magical me! I have just installed that extension this minute and it is working delightfully! Thanks for the help.....much appreicated.
  • Immersion, yes i thought vbulletin would work that way.....but it is the general idea that I liked - ie after x posts, the adsense pops up. I worked so late last night tweaking my site - I just LOVE Vanilla......and Mark and you all are so wonderfully helpful.
  • yeah i will go searching for the best way to do it, as maybe i can use the commentgrid things, however i think this is too advanced for me, as i am new to php.
  • TreyTrey New
    edited July 2006
    heres what I was able to do for this. its not an extension of some sort because I dont know how I would be able to put it in there but it is pretty easy to do.

    It does requiring editing 1 file, but you wont be taking anything out, you're just adding onto it.

    If you look in the themes folder / directory you'll see the file comments.php open that up to edit it. go to like 130 or 129 something like that and you'll see this..

    }

    $CommentList .= '</ol>
    </div>';
    add the following right before that

    if($RowNumber == 1){
    $CommentList .= '<li><div style="text-align:center;">
    GOOGLE CODE HERE
    </div></li>';
    }
    so it would then look like..

    </div>
    </li>';
    // the following little block wasnt there, I just added it so I could get the adsense in here :)
    if($RowNumber == 1){
    $CommentList .= '<li><div style="text-align:center;">
    <script type="text/javascript"><!--
    google_ad_client = "pub-YOUR_GOOGLE_ID";
    google_ad_width = 468;
    google_ad_height = 60;
    google_ad_format = "468x60_as";
    google_ad_type = "text_image";
    google_ad_channel ="";
    google_color_border = "FFFFFF";
    google_color_bg = "FFFFFF";
    google_color_link = "0000FF";
    google_color_text = "000000";
    google_color_url = "008000";
    //--></script>
    <script type="text/javascript"
    src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
    </script></div></li>';
    }
    }

    $CommentList .= '</ol>
    </div>';

    if you look at that you'll see the "if($RowNumber == 1){" you can change that 1 to whatever number you would like, and thats the posts number it will show up after.
This discussion has been closed.