A quick question regarding plugins.
Added by Benjamin FRAUD over 14 years ago
Hi!
I'm working on bringing some stuff to Redmine, related to our business logic, and in order to keep the app evolutive, I need to bring these changes through plugins.
The thing is, when I develop, for instance, two functionnalities on a project view, it seems impossible to encapsulate one modification in a plugin and the other one on a second, cause the second overrides the first, see?
So, once I developped my personnal plugin including some changes on the file projects/view.rhtml for example, how do I make it still possible to install a project plugin from this website's list without overriding my changes?
Thanks!
Replies (6)
RE: A quick question regarding plugins. - Added by Felix Schäfer over 14 years ago
You can't only one view file gets rendered, but there are efforts to bring more hooks into views in which each plugin could in turn inject code in the view rather than superseeding it.
RE: A quick question regarding plugins. - Added by Jean-Baptiste Barth over 14 years ago
benjamin agullana: you can use Redmine's hooks in your plugins like the core does, if the 2 plugins are yours. Maybe engines also provides some specific render method or options, but you'll have to look deeper in their code or doc for that.
@developpers: Rails view rendering is getting better and better regarding performance. We could easily split some views into many parts and add more hooks. But maybe it has to be benchmarked, I don't know if there are performance problems with the hook mechanism.
RE: A quick question regarding plugins. - Added by Benjamin FRAUD over 14 years ago
Alright, thank you for your answers.
I don't know muck about Redmines's hooks though, could you tell me more about them?
RE: A quick question regarding plugins. - Added by Jean-Baptiste Barth over 14 years ago
Many informations can be found in the dedicated wiki page : Hooks
Here is the simplest version in your case (with 2 plugins from you..) :- in the first plugin, you insert in your views a call_hook helper like this :
<%= call_hook(:view_hook_for_my_first_plugin) %>
- in the second plugin, you can use this hook by including something like this in a file required in your init.rb :
module MySecondPlugin class Hooks < Redmine::Hook::ViewListener render_on :view_hook_for_my_plugin_1, :partial => 'path/to/a/view/inserted/in/that/page' end end
I often use it in sidebar for instances, to avoid second plugin to erase what first one did. You can do many other things with hooks, everything shoud be in the wiki page.
RE: A quick question regarding plugins. - Added by Jean-Baptiste Barth over 14 years ago
Oops, render_on :view_hook_for_my_first_plugin,
, not render_on :view_hook_for_my_plugin_1,
RE: A quick question regarding plugins. - Added by Eric Davis over 14 years ago
Jean-Baptiste Barth wrote:
@developpers: Rails view rendering is getting better and better regarding performance. We could easily split some views into many parts and add more hooks. But maybe it has to be benchmarked, I don't know if there are performance problems with the hook mechanism.
Agreed. If you (or anyone) notice any views that could be split easily, open a new feature request for it (category: Code Cleanup).
Eric Davis