Please upgrade here. These earlier versions are no longer being updated and have security issues.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.

embedding adbrite code in discussion's helper_functions.php

AoleeAolee ✭✭
edited May 2011 in Vanilla 2.0 - 2.8
hi guys,

i just have a question in application/vanilla/views/discussion/help_functions.php

what is so special at the line 55 <div class="Message"> --

when i embed my adbrite code after this line and try to load the page...

the page redirects to a blank page, only displaying the ads.

but if i put the adbrite code anywhere it doesn't redirects and displays the page correctly together with the ad?

problem occurs when i put the code inside the block
<div class="Message">
..
..
</div>
is there a special trapping for Javascript codes here?

thanks.

Comments

  • AoleeAolee ✭✭
    edited May 2011
    try this example in the file

    <div class="Message"> <script> document.write("see what i mean?"); </script> <?php $Sender->FireEvent('BeforeCommentBody'); ?> <?php $Object->FormatBody = Gdn_Format::To($Object->Body, $Object->Format); $Sender->FireEvent('AfterCommentFormat'); $Object = $Sender->EventArguments['Object']; echo $Object->FormatBody; ?> </div>
  • ToddTodd Vanilla Staff
    Have you considered trying the pockets plugin?
  • AoleeAolee ✭✭
    edited May 2011
    hi todd, thanks for the quick reply, yes i have tried it but unfortunately it doesnt have the option to insert script/html within the messages area. im planning to do something like this
    image

    so when i plug javascript code inside the <div class="message"> block it doesn't work.
  • AoleeAolee ✭✭
    have anyone managed to do this?
  • ToddTodd Vanilla Staff
    I'd recommend using your theme's hooks file or making a plugin. In that file you can hook into either of these two events:
    public function DiscussionController_BeforeCommentBody_Handler ($Sender, $Args) {
    static $First = FALSE;
    if (!$First)
    return;
    $First = FALSE;

    echo 'Adbrite!!!';
    }
    public function DiscussionController_AfterCommentBody_Handler ($Sender, $Args) {
    static $First = FALSE;
    if (!$First)
    return;
    $First = FALSE;

    echo 'Adbrite!!!';
    }
    How did I find these events? Check out the very helpful Eventi plugin. When you turn it on it shows you all of the events on a page.

    You can also read more about theme hooks at http://vanillaforums.org/docs/theme-hooks.
  • AoleeAolee ✭✭
    Thanks so much Todd! your the man!
  • AoleeAolee ✭✭
    edited May 2011
    Hi just for everyones info. i found the culprit. it's the Emotify plugin causing problem. you can't do document.write when the page has already loaded.

    emotify plugin queries the message body of the discussion ( <div class="message"> </div>) to replace the chars with icons. but since the adbrite uses document.write in their code, it conflicts with it. emotify plugin re-fires the document.write code.

Sign In or Register to comment.