Difference between revisions of "Menus"

From Request Tracker Wiki
Jump to navigation Jump to search
m (Fix links)
 
m (7 revisions imported)
 
(3 intermediate revisions by the same user not shown)
Line 31: Line 31:
  # Remove the 'home' root menu item (don't try this at home!)
  # Remove the 'home' root menu item (don't try this at home!)
  Menu->delete('home');
  Menu->delete('home');
# The 'home' menu item key comes from the first argument to ->child where
# the Home link is added in Elements/Tabs.  The key for retrieving our new
# Corporate link as above above would be 'bps'.
  </%init>
  </%init>
The objects returned by the functions <code>Menu()</code> and <code>PageMenu()</code> are <code>RT::Interface::Web::Menu</code> instances.  Documentation for the <code>child</code> and <code>delete</code> methods used above, plus more, is available by running <code>perldoc /opt/rt4/lib/RT/Interface/Web/Menu.pm</code>.

Latest revision as of 16:14, 6 April 2016

There are three types of menus in RT4: the main menu, the page menu, and the page widgets.

Modifying Menus

All of these menus can be altered, culled, and augmented by CustomizingWithCallbacks. The main RT menu can be modified from the "Menu" object in the callback. Here is an example of adding a new root menu item to RT:

local/html/Callbacks/*/Elements/Tabs/Privileged

<%init>
# Add a brand new root menu item
my $bps = Menu()->child(
    'bps', # any unique identifier
    title => 'Corporate',
    path  => 'http://bestpractical.com'
);

#Add a submenu item to this root menu item
$bps->child(
    'wiki',
    title => 'Wiki',
    path  => 'http://wiki.bestpractical.com',
);

#Retrieve the 'actions' page menu item
if (my $actions = PageMenu->child('actions')) {
    $actions->child(
        'newitem',
        title => loc('New Action'), path => '/new/thing/here',
    )
}

# Remove the 'home' root menu item (don't try this at home!)
Menu->delete('home');

# The 'home' menu item key comes from the first argument to ->child where
# the Home link is added in Elements/Tabs.  The key for retrieving our new
# Corporate link as above above would be 'bps'.

The objects returned by the functions Menu() and PageMenu() are RT::Interface::Web::Menu instances. Documentation for the child and delete methods used above, plus more, is available by running perldoc /opt/rt4/lib/RT/Interface/Web/Menu.pm.