Hey @Todd, if I wanted to remove the NewDiscussion (or any) module from the Discussion's Index method, how could I do that with a plugin or theme? I see no RemoveModule function which would've been my best guess.
@Lincoln said:
Ah HA, the Controller's Assets are public! Answer:public function DiscussionController_BeforeDiscussionRender_Handler(&$Sender) {
unset($Sender->Assets['Panel']['NewDiscussionModule']);
}
anything you know of offhand for Vanilla 2.1.
(in my case, specifically removing the SidemenuModel).
presently hiding module in css works, but removing a module would be a nice feature, if it isn't already implemented.
It's a necropost but its still the same question!
I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.
I see no RemoveModule function which would've been my best guess.
css is a good alternative I think .
thx for the reply. Unfortuantely I wasn't looking for imaginary things.
removing via css is not the best thats why I stated what I did.
I have used this to remove modules and used AddModule to add ...
$this->Head-> RemoveModule('ElModulo');
what is this? Did you specifically remove modules in 2.1 with the imaginary function that doesn't exist.
Did you actually see that "$this->Head-> RemoveModule('ElModulo');" or are you just posting imaginary stuff again
I know i could override function.
But the statement that lincoln posted for previous version would be nice if it worked in vanilla 2.1.
Hoping someone in the know would know, and was hoping to avoid imaginary things.
But it's not crucial for what I am doing.
I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.
@hgtonight said:
Modules are just assets in an asset container which are part of a controller.
Assets get rendered when the asset container is rendered.
Unsetting the asset before rendering should do what you need.
public function Base_Render_Before($Sender) {
unset($Sender->Assets['Panel']['SideMenuModule']);
}
Of course you would want to put a conditional in there if you only want to remove it on some pages. I just tested this on a local dev environment.
thanks hg - proof that what lincoln suggested it works in 2.1 for the Base_Render_Before
But in my case the module in question is added later. So it is still too early at that point. I'll experiment thanks. At least I know unset works for modules added prior to
Render_Before. and I haven't found an event where I can unset later, even directly after profile controller method getuserinfo is called in my create function. So maybe I'll emulate getuserinfo and solve the issue.
I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.
It's generally not good practice to load up Base_Render_Before. It's the laziest hook, and because events do not prioritize order of hooks, you can get into a mess real quick (plus there's the performance hit of needlessly firing it on every. single. page.) It's really a last-resort hook, and perhaps means you should look at adding an event to core somewhere (or look harder for the right one).
Whatever is adding a module past Base_Render_Before is probably doin' it wrong.
(This is the part where you tell me it's something I wrote doing it...)
the problem was getuserinfo loaded a module in my plugin create routine
based on EditMode(FALSE) or TRUE different modules get added
I had so many iterations of testing things
I just put EditMode(FALSE) in the wrong place and assumed it didn't work.
my logic was a moving target. I narrowed down to getuserinfo loading the module (except not the one I wanted. I tried a test but put the EditMode(FALSE) after the getuserinfo call (duh!). or in other events that didn't pertain, so i got it resolved.
I try to use the Profile Discussion or whatever instead of base. I suppose that cuts down a little but still hits all the assets in the page.
I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.
Comments
(in my case, specifically removing the SidemenuModel).
presently hiding module in css works, but removing a module would be a nice feature, if it isn't already implemented.
It's a necropost but its still the same question!
I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.
I have used this to remove modules and used AddModule to add ...
css is a good alternative I think .
$this->Head-> RemoveModule('ElModulo');
❌ ✊ ♥. ¸. ••. ¸♥¸. ••. ¸♥ ✊ ❌
thx for the reply. Unfortuantely I wasn't looking for imaginary things.
removing via css is not the best thats why I stated what I did.
what is this? Did you specifically remove modules in 2.1 with the imaginary function that doesn't exist.
Did you actually see that "$this->Head-> RemoveModule('ElModulo');" or are you just posting imaginary stuff again
I know i could override function.
But the statement that lincoln posted for previous version would be nice if it worked in vanilla 2.1.
Hoping someone in the know would know, and was hoping to avoid imaginary things.
But it's not crucial for what I am doing.
I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.
Modules are just assets in an asset container which are part of a controller.
Assets get rendered when the asset container is rendered.
Unsetting the asset before rendering should do what you need.
Of course you would want to put a conditional in there if you only want to remove it on some pages. I just tested this on a local dev environment.
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.
no it worked on 2.0 , I guess the method needs to be there to be able to apply it. sorry ...
❌ ✊ ♥. ¸. ••. ¸♥¸. ••. ¸♥ ✊ ❌
thanks hg - proof that what lincoln suggested it works in 2.1 for the Base_Render_Before
But in my case the module in question is added later.
So it is still too early at that point. I'll experiment thanks. At least I know unset works for modules added prior to
Render_Before. and I haven't found an event where I can unset later, even directly after profile controller method getuserinfo is called in my create function. So maybe I'll emulate getuserinfo and solve the issue.
I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.
Consider my curiosity peeked. How does one load a module after rendering?
Through JS?
EDIT - Glad my 1000th comment was about learning something
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.
It's generally not good practice to load up Base_Render_Before. It's the laziest hook, and because events do not prioritize order of hooks, you can get into a mess real quick (plus there's the performance hit of needlessly firing it on every. single. page.) It's really a last-resort hook, and perhaps means you should look at adding an event to core somewhere (or look harder for the right one).
Whatever is adding a module past Base_Render_Before is probably doin' it wrong.
(This is the part where you tell me it's something I wrote doing it...)
hgtonight set me straight! His eyes are 20/20
the problem was getuserinfo loaded a module in my plugin create routine
based on EditMode(FALSE) or TRUE different modules get added
I had so many iterations of testing things
I just put EditMode(FALSE) in the wrong place and assumed it didn't work.
my logic was a moving target. I narrowed down to getuserinfo loading the module (except not the one I wanted. I tried a test but put the EditMode(FALSE) after the getuserinfo call (duh!). or in other events that didn't pertain, so i got it resolved.
I try to use the Profile Discussion or whatever instead of base. I suppose that cuts down a little but still hits all the assets in the page.
I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.