Project

General

Profile

Actions

Feature #2194

closed

Have many controllers associated with a single menu_item (especially for plugins)

Added by Jean-Baptiste Barth over 15 years ago. Updated over 15 years ago.

Status:
Closed
Priority:
Low
Assignee:
-
Category:
Plugin API
Target version:
-
Start date:
2008-11-15
Due date:
% Done:

0%

Estimated time:
Resolution:

Description

I'm building a plugin with many controllers. I'd like to have a way to specify in my plugin's init.rb how to link theses controllers with a single menu item. If I'm not wrong, it's not possible for the moment. As the plugin has its own single tab in the "project_menu", when you jump from a controller to another, the tab isn't selected anymore, making my users feel lost (I just suppose).

The selection of a tab seems to be handled by a simple comparison between the menu item name and the current controller name. In the attached diff I've changed a bit the way item is detected as being the selected one. There should be no impact on existing menu calls. Perhaps you'll prefer another implementation, or tell me this is completely useless for other people, which I can easily imagine.

USAGE
It can be used as an option for "menu" method in yourplugin/init.rb : :for => [:controller1, :controller2, ...]
Note that the comparison with the menu name as no more effect if a ":for" array is defined, i.e. if you name your menu "mycontroller" and a ":for" option is present, menu item won't be selected unless ":mycontroller" is present in the ":for" option.


Files

menu_manager.diff (1.18 KB) menu_manager.diff Jean-Baptiste Barth, 2008-11-15 05:45
Actions #1

Updated by Markus Knittig over 15 years ago

+1

Actions #2

Updated by Jean-Philippe Lang over 15 years ago

  • Status changed from New to Closed

I'd like to have a way to specify in my plugin's init.rb how to link theses controllers with a single menu item. If I'm not wrong, it's not possible for the moment.

It is possible. For example TimelogController uses the same menu item as IssuesController.
MenuManager adds a class method menu_item to ApplicationController.

It can be used like this in your plugin controllers:

class SomeController < ApplicationController
  # use :foo as the default menu item for this controller
  menu_item :foo

  # use a different menu for a particular action
  menu_item :bar, :only => :edit
end
Actions #3

Updated by Jean-Baptiste Barth over 15 years ago

Great, thank you !
And sorry I've missed that..

Actions

Also available in: Atom PDF