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.
Force module on all pages
alan0209
New
I embarrassed to have to ask this as I sure it must be simple and I have tried a number of things from these discussions that I thought might be relevant without luck, so....how do I force a specific module to show in the panel on all pages? For example I am considering having the Categories module (the one that list all of the available categories along with the number of discussions in each) in the sidebar of every page, even the categories page, message page etc. How can I force this to happen?
I am running 2.1.1
Thanks
Alan
0
Comments
Add that to a plugin.
Or add this to your master template
{module name="CategoriesModule"}
.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.
Thanks hgtonight. Is there something I can add to either of the above so I can insert it between existing modules that the panel renders?
you can sort modules.
http://vanillaforums.org/discussion/comment/163830/#Comment_163830
finding config statements. I think this in here somewhere...
http://vanillaforums.org/discussion/20231/how-to-become-somewhat-adept-at-modifying-vanilla-to-meet-your-needs-for-free
but definitely in here
http://vanillaforums.org/discussion/comment/207335/#Comment_207335
I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.
Oh that's really cool. I'd come across the module array options in the config file but didn't realize it would apply to extra bits I added via the render event. Sweet.
I guess the missing piece here is how do I stop two copies of the module appearing on pages that already have it? My testing seems to indicate that the routine above will add the Categories module to every page, even those where it already exists. How can I check to see if it will automatically get added to that page and not add a second copy?
The plugin method I posted should check to see if the module exists before adding it.
The template way will never check and will always be displayed.
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.
@alan0209
or themehooks will work as well. @alan0209 , if you are unfamiliar with themehooks, here is an example
http://vanillaforums.org/discussion/comment/210958#Comment_210958
there is also one in the mobile theme as well.
I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.
Hmm I must be doing something wrong then. When testing I simply added the following to my themehooks file
That adds a the categories menu to the panel of my homepage (the categories page) as I wanted. If I click to go into a specific category though then I end up with 2 copies of the menu in the panel. If I remove the above code then I am back to no categories panel menu on the Categories page and a single copy when within a category. Any suggestions?
I wouldn't use Base_Render_Before, but add it to any controller "manually" by using something like
CategoriesController_Render_Before
. But if you want to use Base_Render_Before, you might want to check some things:Don't know if those are arrays and the code works like that, but you get the idea...
Okay, quick test...
Either this:
or that
AddModule doesn't make duplicate checks
Ah Ok thanks for that. The top one was working (avoiding duplicates) but crashing the site when I tried to go to activities, dashboard etc (Something has gone wrong. etc). The bottom one wasn't causing crashes but was still doubling up. I've merged the two and ended up with
Which seems to do the job.
Presumably there is something specific tot he Categories module that doesn't work if it is on a profile related page. I'll have a play and see if I can work out what is breaking.
Thanks again
I'd assume it is because profile is in /applications/dashboard application while the categories module is in /applications/vanilla. Try if copying
/applications/vanilla/views/modules/categories.php
to/applications/dashboard/views/modules/categories.php
helps.It is not the most elegant solution, but maybe the most simple (if it is working that way)
Ah, I misread the source.
I would rather modify the module class to call the view and application folder explicitly than copy views around. This way, you create a custom module and just unset all instances of the original.
Then change your plugin hook to be:
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.
Your a developer, I'm a slaughter...
Thanks for more good tips. In the end I decided I wanted to pool the menus from DiscussionFilter and the Categories module so I made a new module with bits from both. I now have a single menu that works on all pages. Might prove unwieldy in the real world but seems to be working OK for the moment so I'll see how it goes.