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.
Overwrite plugin's view in theme
![cannafire](https://secure.gravatar.com/avatar/f7579bb50e52e3d566794fcf197eaba3/?default=https%3A%2F%2Fvanillicon.com%2F74607128fc3d80d11827076cbe6fb169_100.png&rating=g&size=100)
I'm coding a theme and I can't seem to find a way to change a plugin's output within the theme.
Say, you have \plugins\Foo\class.foo.plugin.php
:
class FooPlugin extends Gdn_Plugin { public function Base_BeforeDiscussionTabs_Handler($Sender) { echo 'bar'; } }
Is it at all possible to have like \themes\sometheme\views\plugins\Foo\foo.php
or something along those lines? And then perhaps extend the plugin's class within my theme overwriting the method in question? I'm not quite sure what gets autoloaded...
0
Comments
Plugins that have simple calls to
echo
cannot be overridden by your theme. I recommend using css as much as possible to change the look of things in this case.Not all plugins fetch their views in the correct way to be themable, but a lot do. In order for a plugin to be themable you need to see a call to
Render()
that looks something like:In this case there'd be a view called
/plugins/Foo/views/myview.php
. Then in order to override the view you'd add/themes/YourTheme/views/myview.php
to your theme.@Todd: Is this going to get a programming guideline anwhere soon. It would be cool to have that reliably integrated. Thanx for info.
I've never been a fan of this. I have made many of my pluings themable but at first I used
current_theme/views/lowercasepluginnname/view.php
then eventually I have been moving towardscurrent_theme/views/plugins/PluginName/view.php
grep is your friend.