I'm looking for a part-time remote job.

Hire me


I'm the author of:

Mastering Redmine is a comprehensive guide with tips, tricks and best practices, and an easy-to-learn structure.

Check the book's project or

Buy the book

Social pages of the book:

By buying this book you also donate to Redmine (see this page).


Follow me:

Adding custom content

This is how the content of the Extended Profile plugin is added to the author box...

To support customization the Author Box provides the :view_sidebar_author_box_bottom hook, which gets executed with the following data in the context:
  • :user -- the user object, for which the author box is rendered;
  • :count -- the total number of users, for whom author boxes are rendered (may be used to determine the rendered size of custom data in the box, as multiple author boxes are slightly smaller).
Also the following standard data are available, which may be interesting for you:
  • :project -- the project object, for which the author box gets rendered;
  • :request -- the request object containing all the details about the request.

The hook can be used in the following way:

class ExtendedFieldsHook  < Redmine::Hook::ViewListener
    render_on :view_sidebar_author_box_bottom, :partial => 'author_box/custom_data'
end

Here author_box/custom_data (use your own directory and file names) refers to the partial view file author_box/_custom_data.html.erb, the content of which can look like:

In this sample code I display the progress bar showing the percentage of projects, the user participates in (is member of).
<% all_projects =  Project.count(:conditions => Project.visible_condition(User.current)) %>
<% user_projects = user.memberships.all(:conditions => Project.visible_condition(User.current)).count %>
<%= progress_bar(user_projects * 100 / all_projects, :width => '120px', :legend => "#{user_projects} of #{all_projects} projects") %>

This renders the author, box which looks like:

Sample author box

See also:

author.png View - Sample author box (16.4 KB) Andriy Lesyuk, 05 Oct 2012 23:53

Terms of use | Privacy policy