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

How to not display a module


I do not want to show DiscussionFilterModule in the index page. What's the best and safest way to achieve this?

Thanks :D


  • Options
    R_JR_J Ex-Fanboy Munich Admin

    If you simply do not want to show it, and ask for the simplest solution, using CSS and display:none would be the answer.

    The module will nevertheless be built and the html will be transferred to the client. So if you are searching for a way to avoid that, you need some PHP code => a themehooksfile or a plugin

    The DiscussionFilterModule is a Module in the Panel which is an Asset (just like the Head, the Content and the Foot). Vanillas Gdn_Controller class has a property "Assets" which is an array with the four assets mentioned above. Each module that is added to an asset wiv the addModule() method is just another key in that array. So the trick is to unset Gdn::controller()->Assets['Panel']['DiscussionFilterModule']. You can basically do that at any time after the module has been added (which is done in the constructor of the Gdn_Controller).

    Before each of the assets is rendered, an event is thrown (in Gdn_Controller->renderAsset()). That's where I would do it.

        public function base_beforeRenderAsset_handler($sender, $args) {
           // That check is not needed, I guess. But anyway...
           if (!array_key_exists(
           )) {

    On the other hand, that event is fired 4 times (for each asset). Maybe it would be more efficient to put that one line into base_render_before

    public function base_render_before($sender) {

    If it should only be excluded from the Discussions page, make it discussionsController_render_before

  • Options

    Thank you very much for the detailed explanation!!

Sign In or Register to comment.