HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.

Anyone wants to get things appear there and there real quick? Here is a dirty solution

vorapoapvorapoap New
edited April 2013 in General Banter

This is not recommended for novice user (hack core) and well.. but I am Vanilla newbie. so if anyone want to pierce me here it is ok. I just want something to get the job done quickly.

  1. Open /library/core|class.pluggable.php
  2. Find "public function FireEvent($EventName)"
  3. Replace the whole function with this code....

           public function FireEvent($EventName) {
              if (!$this->ClassName) {
                 $RealClassName = get_class($this);
                 throw new Exception("Event fired from pluggable class '{$RealClassName}', but Gdn_Pluggable::__construct() was never called.");
              }          
      if ($_GET['DEBUGEVENT']) echo $EventName.'<br>';
      if (function_exists("On".$EventName)) {
        call_user_func("On".$EventName, $this, $this->ClassName, $EventName);
      }
    
      // Look to the PluginManager to see if there are related event handlers and call them
      return Gdn::PluginManager()->CallEventHandlers($this, $this->ClassName, $EventName); }
    

^^^ sorry for bad indentation, I am not get used to this [C] button

  1. Now open /index.php
  2. Find "require_once(PATH_ROOT.'/bootstrap.php');" (should be on line 41)
  3. Insert this code one line after
    require_once(PATH_ROOT.'/x-viewlib.php');
  4. Of course x-viewlib.php can be any name. In this file you will declare any OnXXXXX where XXXXX is the EventName

For this example, I do something like this

<?php
function OnAfterComment() {
    static $render = 0;
    if ($render) return;


    PrintAdsense(true);
    $render = 1;

}

So you wonder how to find out the event name you want?
Get to your forum URL and add ?DEBUGEVENT=1 at the end of URL (must before hashtag symbol '#') for example
http://www.yourforum.com/activity?DEBUGEVENT=1

So here.. you find out immediately what function name to declare.

Comments

  • KasperKasper Vanilla Staff

    Or just install Eventi: http://vanillaforums.org/addon/eventi-plugin ;-)

    Kasper Kronborg Isager (kasperisager) | Freelance Developer @Vanilla | Hit me up: Google Mail or Vanilla Mail | Find me on GitHub

  • this is reinventing the wheel

    you would use

    DiscussionController_AfterComment_Handler

    or simply

    Base_AfterComment_Handler

    hooks

    Pleas read the docs how to write plugins or themehooks.

    grep is your friend.

  • peregrineperegrine MVP
    edited April 2013

    @vorapoap

    perhaps "pierced", but interesting and creative. thx for the idea. Keep the ideas coming, don't let a minor piercing stop you.

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

  • @vorapoap

    I agree with peregrine, very creative :D

    Search first

    Check out the Documentation! We are always looking for new content and pull requests.

    Click on insightful, awesome, and funny reactions to thank community volunteers for their valuable posts.

  • @x00

    To do that I will have to create a class and register as a plugin? I may have done that when things are more settled on my side. But well.. I was moving some code out of the default.master.php .. so trying to do it real quick without plugin.

  • It is hardly more complicated that what you are doing.

    I recommend themehooks too.

    Modding the core is not the way to go unless it is a pull request, or you are maintaining a fork, you want something that is update friendly.

    grep is your friend.

Sign In or Register to comment.