Book Image

Redmine Plugin Extension and Development

By : Alex Bevilacqua
Book Image

Redmine Plugin Extension and Development

By: Alex Bevilacqua

Overview of this book

Table of Contents (16 chapters)
Redmine Plugin Extension and Development
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

View hooks


The primary use of hooks in Redmine is to inject functionality into an existing view.

A view hook is executed while the HTML code of a view is being rendered.

View hooks are likely to be the most frequently used type of hook by plugin authors. Through these hooks, we can add functionality from our plugins to existing Redmine views and partials.

As an example, let's add the ability to associate knowledgebase articles with an issue. We'll implement this in a similar fashion to how issues can be associated with each other.

In order to display this association, we will extend the relevant issue views using view hooks. To accomplish this, the first step is to create a class that extends Redmine::Hook::ViewListener:

module RedmineKnowledgebase
  class Hooks < Redmine::Hook::ViewListener
    render_on :view_issues_show_description_bottom,
              :partial => 'redmine_knowledgebase/hooks/view_issues_show_description_bottom'
  end
end

This file will be saved to our plugin's lib folder...