It looks like you're new here. If you want to get involved, click one of these buttons!
I'm working on a theme, and I'd like to change the functionality of the Tagging plugin. Namely, I'd like to override class.tagmodule.php in my theme.
I know I can override the views in my theme, but what is the practice for overriding plugin modules like this?
x00
Don't PM about development, I'm not currently taking on clients MVP
I provide this functionality on some of my plugins, especial where I am already overriding core views.
It is not a standard thing though, But I support it in principle, as it is consistent with application views
The principle of it is like so
$PluginFolder = basename(dirname(__FILE__));
$ThemeFolder = strtolower($PluginFolder);
$Sender->ControllerName='';
$Sender->ControllerFolder='';
$ThemeViewLoc = CombinePaths(array(
PATH_THEMES, $Sender->Theme,'views', $ThemeFolder
));
if(file_exists($ThemeViewLoc.DS.strtolower($Sender->RequestMethod).'.php')){
$Sender->ApplicationFolder= '';
$Sender->ControllerName=$ThemeFolder;
}else{
$Sender->ApplicationFolder='plugins/'.$PluginFolder;
}
I use lower case folders within themes views folder as this is consistent with the current style
Don't PM about development, I'm not currently taking on clients.
grep is your friend.
Answers
You can try extending the specific class and then rewriting whatever function you want to override in the parent class. This is one of the reasons why my theme comes with a plugin.
- Spam
- Abuse
- Troll
0 • Off Topic Insightful Awesome LOL •How do I structure my folders to extend a plugin? Do I need a
modulesfolder, or should I be putting this somewhere else?- Spam
- Abuse
- Troll
0 • Off Topic Insightful Awesome LOL •You nees to replicate the original structure.. copy the original file and folders you want to override into the theme.
Vanilla Wiki, Tastes Great! 31,000 viewers can't be wrong.
- Spam
- Abuse
- Troll
0 • Off Topic Insightful Awesome LOL •I'm just not getting it. :(
In my custom theme, I want to override
TagModule::ToString(). It exists invanilla-root/plugins/Tagging/class.tagmodule.php. Can I override this in my theme's folder, allowing me to distribute a theme with custom functionality? If so, how should my folder structure be set up?I've tried putting this file in the following locations, to no avail:
vanilla-root/themes/my-theme/class.tagmodule.phpvanilla-root/themes/my-theme/modules/class.tagmodule.phpvanilla-root/themes/my-theme/plugins/Tagging/class.tagmodule.php- Spam
- Abuse
- Troll
0 • Off Topic Insightful Awesome LOL •There may be better methods, but this is what I do:
If you know where this function is called from (probably from a Fired Event), you can temporary buffer the output and the grab the results and filter them to your liking. In your case, I would look for the contents of
TagModule::Tostring()such as a div with a specific class/ID and then replace it with whatever you want. The DOM document is perfect for this.Here is an example of what I do to make all of the meta elements fit into an unordered list. I pulled this code snippet of the traditional plugin views/discussion/helper_functions/ line 76:
- Spam
- Abuse
- Troll
0 • Off Topic Insightful Awesome LOL •@mcu_hq Hmm... this seems a bit dirty. I was hoping to just be able to have my theme dictate the module to load, like it does with views.
Do themes not allow that functionality?
- Spam
- Abuse
- Troll
0 • Off Topic Insightful Awesome LOL •Unfortunate. :(
- Spam
- Abuse
- Troll
0 • Off Topic Insightful Awesome LOL •I missed a piece... x00 do you put your code in helper_functions.php in your theme?
What to do if I get a Bonk Error?
Vanilla Wiki : Join and help edit our Wiki! | View all Vanilla issues on GitHub | Report a new Vanilla issue on GitHub
Deploying a new Forum and adding a Theme | Give thanks to the Vanilla Developers!
- Spam
- Abuse
- Troll
0 • Off Topic Insightful Awesome LOL •no it goes the
Base_Render_Beforehook or a Create hook. basically any controller hook just before render.So the view is goign to be name of the request method lowercase.
Don't PM about development, I'm not currently taking on clients.
grep is your friend.
- Spam
- Abuse
- Troll
0 • Off Topic Insightful Awesome LOL •