W
W
WordPress WooCommerce2017-04-10 18:17:09
Redmine
WordPress WooCommerce, 2017-04-10 18:17:09

Does anyone have a simple example of using hooks in Redmine?

I am exploring the possibilities of Redmine in terms of writing plugins. So far, I'm afraid of its redundancy and complexity in this part.
I would really appreciate a kick in the right direction.
Imagine a task - to add arbitrary JS code to the head section of all pages.
I found that there is a suitable hook for this https://github.com/redmine/redmine/blob/master/app...
So I can hook on to it and add my JS there.
I created a plugin according to the instructions, it messed up a bunch of files.
Can I somehow briefly pull this hook right in init.rb?
I would like some short example that adds some JS code through this hook.
This will help me move forward with my task :)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Artem Gladyshev, 2017-04-13
@maxxannik

In init.rb, pulling it is not very nice.
I usually do this:
in init.rb I write in the lib plugin folder, I create a hooks.rb file

module PluginName
  class Hooks  < Redmine::Hook::ViewListener
    render_on(:view_layouts_base_html_head , partial: 'hooks/layouts_base_html_head ')
  end
end

in the plugin_name/app/views folder I create the hooks folder and create the _layouts_base_html_head.html.erb file
in it and paste it into it, js or whatever else I need.
I think it’s enough detail so that you can move on =)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question