Edit the top menu
Added by Jeffrey Jones over 14 years ago
Hello all,
Someone asked me to add a link to the top menu of RedMine (The "Home, My page, Projects" etc. one).
"No problem" I thought as I went into the base.html.erb file expecting there to be a nice simple list. Good lord was I mistaken :)
I tracked it back to the lib/redmine/menu_manager.rb but I still cannot find out how I can add a link to the menu (I need a link to a specific project's "Documents" index page).
Could anyone point me to the location where I can make the edit?
Cheers
Jeff
Replies (11)
RE: Edit the top menu - Added by Holger Just over 14 years ago
Jeff,
You can create a plugin and add the link that way. Please see the Plugin Tutorial for more information. A real life example can be found here: http://github.com/edavis10/redmine-timesheet-plugin/blob/master/init.rb#L37
--Holger
RE: Edit the top menu - Added by Jeffrey Jones over 14 years ago
Thanks for that,
seems a bit of a faff just to add a menu item but I can see how it may be useful as we add more tweaks.
Cheers
RE: Edit the top menu - Added by sean chan over 14 years ago
it seems that you should edit the "lib\redmine.rb" files to achieve that
please see my Question "How can I add a MenuItem "...I cant figure it out either,but Im pretty sure we should modify the 'lib\redmine.rb' to get it done
RE: Edit the top menu - Added by Holger Just over 14 years ago
You should not edit lib/redmine.rb as this prevents easy updates.
You can however create a simple plugin as stated above. To do that, perform the following steps:
- Run
script/generate redmine_plugin add_link
to create a new plugin. - Edit
vendor/plugins/redmine_add_link/init.rb
and put the following code in it:require 'redmine' Redmine::Plugin.register :redmine_rt_link do name 'Redmine Add Link' author 'Holger Just' url 'http://dev.holgerjust.de/projects/redmine-misc' author_url 'http://meine-er.de' version '0.1.0' requires_redmine :version_or_higher => '0.8.0' # caption can also be a i18n symbol or a proc menu :top_menu, :my_link, {:controller => 'my_controller', :action => 'my_action'}, :caption => "My title" end
That way, your menus get added without the need to edit any core redmine files and breaking updatability.
The available options for the menu
function are documented in the Plugin_Tutorial.
RE: Edit the top menu - Added by Dave Holyfield over 11 years ago
This a valid way to add issues and activites links on 2.3.0
# Add menu items menu :top_menu, :issues, { :controller => 'issues', :action => 'index' }, :last => true, :caption => :label_issue_plural menu :top_menu, :all_activities, {"controller"=>"activities", "action"=>"index", "id"=>nil}, :last => true, :caption => :label_activity
Detailed quick instruction (>=2.3)¶
Environment: CentOS 6, Phusion Passenger Apache module
- Open terminal (make sure you are using it as actual site owner (not root) or change files owner latee)
- Use command: cd <pah to your redmine folder>
- Use command: ruby script/rails generate redmine_plugin <my_plugin_name>
- Use command: cd plugins/<my_plugin_name>
- Use some editor to modify your plugin: vi init.rb
- Add on top of file
require 'redmine'
- Replace plugin name etc with your desired info
- add before string end these new lines
# Add menu items menu :top_menu, :issues, { :controller => 'issues', :action => 'index' }, :last => true, :caption => :label_issue_plural menu :top_menu, :all_activities, {"controller"=>"activities", "action"=>"index", "id"=>nil}, :last => true, :caption => :label_activity
- Save your changes
- use command: /etc/init.d/httpd restart
Your init.rb should look something like this:
require 'redmine' Redmine::Plugin.register :top_menu do name 'Top Menu' author 'Me' description 'Adds some items on top menu' version '1.0.0' url 'http://redmine.org' author_url 'http://redmine.org' requires_redmine :version_or_higher => '2.0.0' # Add menu items menu :top_menu, :issues, { :controller => 'issues', :action => 'index' }, :last => true, :caption => :label_issue_plural menu :top_menu, :all_activities, {"controller"=>"activities", "action"=>"index", "id"=>nil}, :last => true, :caption => :label_activity end
RE: Edit the top menu - Added by David Rahusen about 11 years ago
Hey there, the linking to the global issues doesn't work for me, as long as I am currently using the controller within a project...hope you understand what I mean!?
This is what I added to my init.rb
:
menu :top_menu, :top_issues, {:controller => 'issues', :action => 'index', :id => nil}, :caption => :label_issue_plural
That even works, but just as long as I am not within the issues view of project. In that case, the top menu link also points to the issues view of the current project.
Any ideas?
RE: Edit the top menu - Added by Andriy Lesyuk about 11 years ago
David Rahusen wrote:
Any ideas?
Try :project_id => nil
.
RE: Edit the top menu - Added by David Rahusen about 11 years ago
Yeah, thanks, just found that on my own...I've been trying that before, but within the wrong line... -_-
Thanks anyway
RE: Edit the top menu - Added by Franck Sinimalé over 10 years ago
Hi,
Here is my environment :
Redmine version 2.4.3.stable
Ruby version 1.9.2-p0 (2010-08-18) [x86_64-linux]
Rails version 3.2.16
I am a redmine beginner and I know nothing about programming except copy/paste ;) Since I thought I had the same needs as David I tried :
menu :top_menu, :top_issues, { :controller => 'issues', :action => 'index' }, :project_id => nil, :last => true, :caption => :label_issue_all
and many other things in vain...Then, following this post, I found something that works fine for my needs :
menu :top_menu, :all_issues, { :controller => 'issues', :action => 'index', :project_id => @project, :set_filter => 1}, :last => true, :caption => :label_issue_all
With " label_issue_all: Toutes les demandes" in config/locales/fr.yml :)
Thanks all.
RE: Edit the top menu - Added by Dave Holyfield about 10 years ago
An update for 2.5 users to edit lib/redmine.rb to change the top menu.
Removes help menu and adds Activity and Issues.
Redmine::MenuManager.map :top_menu do |menu| menu.push :home, :home_path menu.push :my_page, { :controller => 'my', :action => 'page' }, :if => Proc.new { User.current.logged? } menu.push :projects, { :controller => 'projects', :action => 'index' }, :caption => :label_project_plural menu.push :administration, { :controller => 'admin', :action => 'index' }, :if => Proc.new { User.current.admin? }, :last => true # menu.push :help, Redmine::Info.help_url, :last => true menu.push :all_activities, { :controller => 'activities', :action => 'index' }, :caption => :label_activity menu.push :issues, { :controller => 'issues', :action => 'index' }, :caption => :label_issue_plural end
RE: Edit the top menu - Added by [ Desperados ] over 9 years ago
cool ! how to add a custom url?
I've tried to remove some item but nothing changes: I'm using landing_page plugin and I think it overwrites this customization