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.

"Removing modules from the panel" question again

phreakphreak Vanilla*APP (White Label) & Vanilla*Skins Shop MVP

Hi all,

I digged all discussions i came across dealing with "Removing Modules". I know that there are several ways to make this work but i'm looking for a very comfortable one. I'm not sure if it works also this way.

To send this upfront.
1.) I know how to set the order of modules via the config.php (to bad deleting it from this array doesn't hide modules).
2.) I know that themehooks let me position modules in other places if i want it.
3.) I also know that i can add modules via for example {module name="NewDiscussionModule"} in the template.

I use all of them... but i want something specific. Number 3 is very comfortable but to add, but it doesn't remove the module from another position. And this is exactly what i want to do. I would like to hide the "NewDiscussionsModule" from the panel after i added it via the Smarty tag. It seems like only themehooks allow me this, can't be or?

Is there another way of removing modules (not CSS!) of positions. And if no, can someone help me what the code should look like for the "NewDiscussionsModule".

Thanx a lot, for help.

  • VanillaAPP | iOS & Android App for Vanilla - White label app for Vanilla Forums OS
  • VanillaSkins | Plugins, Themes, Graphics and Custom Development for Vanilla

Comments

  • ShadowdareShadowdare r_j MVP
    edited August 2013

    You may be able to hook into the BeforeAddModule event and prevent the module from getting added there, but @hgtonight's method for unsetting the module is what I would do, and I have used this method before.

    Add Pages to Vanilla with the Basic Pages app

  • hgtonighthgtonight ∞ · New Moderator

    The best way, imo, of removing modules is to unset the modules right before the asset is rendered. Actually, it would be better to never set them in the first place, but I digress.

    http://vanillaforums.org/discussion/comment/186977/#Comment_186977

    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.

  • phreakphreak Vanilla*APP (White Label) & Vanilla*Skins Shop MVP
    edited August 2013

    Hey,

    Yeah i tried that, but i couldn't make it work for some reason i'm not able to find out. Do you see the error?

    class NewDiscussionModule extends Gdn_Module {
        public function Base_Render_Before($Sender) {
            unset($Sender->Assets['Panel']['NewDiscussionModule']);
            }
        }
    
    • VanillaAPP | iOS & Android App for Vanilla - White label app for Vanilla Forums OS
    • VanillaSkins | Plugins, Themes, Graphics and Custom Development for Vanilla
  • ShadowdareShadowdare r_j MVP
    edited August 2013

    With a different class namespace and by extending something like the Gdn_Plugin class, it will work.

    class YourPluginHooks extends Gdn_Plugin {
          public function Base_Render_Before($Sender) {
             if($Sender->Assets['Panel']['NewDiscussionModule'])
                unset($Sender->Assets['Panel']['NewDiscussionModule']);
          }
    }
    

    Add Pages to Vanilla with the Basic Pages app

  • phreakphreak Vanilla*APP (White Label) & Vanilla*Skins Shop MVP
    edited August 2013

    Mmh, both result in an "Something has gone wrong."
    I have to admit i'm working under 2.1. :/

    • VanillaAPP | iOS & Android App for Vanilla - White label app for Vanilla Forums OS
    • VanillaSkins | Plugins, Themes, Graphics and Custom Development for Vanilla
  • ShadowdareShadowdare r_j MVP
    edited August 2013

    I tested your code on 2.1 actually. Are you adding it from a plugin or themehooks? Have you turned on master error view?

    Add Pages to Vanilla with the Basic Pages app

  • phreakphreak Vanilla*APP (White Label) & Vanilla*Skins Shop MVP
    edited August 2013

    "Narf!" i had a typo. Now your code works @Shadowdare!

    class defaultthemehooks extends Gdn_Plugin {
          public function Base_Render_Before($Sender) {
              if($Sender->Assets['Panel']['NewDiscussionModule'])
              unset($Sender->Assets['Panel']['NewDiscussionModule']);
              }
        }
    

    The only thing that wonders me is that @Lincoln mentioned the "Base_Render_Before($Sender)" as not very performant in cases like this, but i don't understand what is going on inside the machine.

    http://vanillaforums.org/discussion/comment/187309/#Comment_187309

    Would this be an issue with 5000 Visitors a day +?

    • VanillaAPP | iOS & Android App for Vanilla - White label app for Vanilla Forums OS
    • VanillaSkins | Plugins, Themes, Graphics and Custom Development for Vanilla
  • ShadowdareShadowdare r_j MVP
    edited August 2013

    I don't think it would be a big issue unless you had complex algorithms running in Base_Render_Before(). This event runs on every single page, so removing one module does impact performance, but just minimally. What do you think, @hgtonight?

    Add Pages to Vanilla with the Basic Pages app

  • vrijvlindervrijvlinder Papillon-Sauvage MVP

    would be nice if you could do it with a config statement like for the guest module , but no :(

    $Configuration['Garden']['Modules']['ShowNewDiscussionModule']= FALSE;

  • LincLinc Detroit Admin
    edited August 2013

    No, my performance concerns are more like at 5 million a day, times dozens of uses.

Sign In or Register to comment.