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.

Where to edit to add image under the "New Discussion" button?

In the left column my "New Discussion" button has been renamed to "Ask a question". But how do I insert an image between the button and the start of the category list?

thx

Best Answer

Answers

  • KasperKasper Scholar of the Bits Copenhagen Vanilla Staff

    To add an image beneath the "New Discussion"/"Ask a Question" button, you'll need to hook into the AfterNewDiscussionButton event in three different controllers (one for the category listings, the discussion listings and the individual discussions) like this:

    public function CategoriesController_AfterNewDiscussionButton_Handler {
        $this->_AddImage(Gdn::Controller());
    }
    
    public function DiscussionsController_AfterNewDiscussionButton_Handler {
        $this->_AddImage(Gdn::Controller());
    }
    
    public function DiscussionController_AfterNewDiscussionButton_Handler {
        $this->_AddImage(Gdn::Controller());
    }
    
    /**
      * Containing your image related code in a private
      * function will save you a lot of copy/pasting.
      */
    private function _AddImage($Sender) {
        echo "Your image";
    }
    

    You could put this code in either a plugin or theme hooks.

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

Sign In or Register to comment.