public function DiscussionController_AfterCommentBody_Handler($Sender)
Inside the method, check that you're in the first post by going like this: $Type = strtolower($RawType = $Controller->EventArguments['Type']);
if ($Type == 'comment') return;
Then insert whatever code you need to output your advertising.
that will show up in every comment, if i'm not mistaken... i think @Raize just wants the ad to show up in the first comment in the thread (the one the thread author creates.)
right... but that handler is called for every comment in the discussion.
Yep. It is called after the discussion body, and then subsequently after every comment. That's why it has to check what the Type of the content it just rendered was, and if it was a comment, bail out and do nothing, otherwise (discussion) display ads.
Have I missed something? I have this horrible feeling like you're going to point out a giant turd on my head...
The OP only wanted the code to show up in the first comment, not in every comment. In my addon i just used a counter to detect the first time the handler is fired.
Comments
public function DiscussionController_AfterCommentBody_Handler($Sender)
Inside the method, check that you're in the first post by going like this:
$Type = strtolower($RawType = $Controller->EventArguments['Type']); if ($Type == 'comment') return;
Then insert whatever code you need to output your advertising.
Vanilla Forums COO [GitHub, Twitter, About.me]
$Type = strtolower($RawType = $Controller->EventArguments['Type']);
$Type = (comment|discussion)
if ($Type == 'comment') return;
Thus, "check the type. if it is a comment, get out and do nothing, else show ads".
Vanilla Forums COO [GitHub, Twitter, About.me]
Have I missed something? I have this horrible feeling like you're going to point out a giant turd on my head...
Vanilla Forums COO [GitHub, Twitter, About.me]
<?php echo $this->FetchView('comments'); ?>
applications/vanilla/views/discussion/comments.php -
line 8-10
if ($CurrentOffset == 0 && !$this->Data('NewComments', FALSE)) { echo WriteComment($this->Discussion, $this, $Session, $CurrentOffset); }
line 14-18
foreach ($CommentData as $Comment) { ++$CurrentOffset; $this->CurrentComment = $Comment; WriteComment($Comment, $this, $Session, $CurrentOffset); }
applications/vanilla/views/discussion/helper_functions.php
$Type = property_exists($Object, 'CommentID') ? 'Comment' : 'Discussion'; $Sender->EventArguments['Type'] = $Type;
<?php $Sender->FireEvent('AfterCommentBody'); ?>
Vanilla Forums COO [GitHub, Twitter, About.me]