RT 4.4.1 Documentation

RT::Interface::Web::Menu

NAME

RT::Interface::Web::Menu - Handle the API for menu navigation

METHODS

new PARAMHASH

Creates a new RT::Interface::Web::Menu object. Possible keys in the PARAMHASH are "parent", "title", "description", "path", "raw_html", escape_title, "sort_order", "class", "target", attributes, and "active". See the subroutines with the respective name below for each option's use.

title [STRING]

Sets or returns the string that the menu item will be displayed as.

escape_title [BOOLEAN]

Sets or returns whether or not to HTML escape the title before output.

parent [MENU]

Gets or sets the parent RT::Interface::Web::Menu of this item; this defaults to null. This ensures that the reference is weakened.

raw_html [STRING]

Sets the content of this menu item to a raw blob of HTML. When building the menu, rather than constructing a link, we will return this raw content. No escaping is done.

sort_order [NUMBER]

Gets or sets the sort order of the item, as it will be displayed under the parent. This defaults to adding onto the end.

target [STRING]

Get or set the frame or pseudo-target for this link. something like _blank

class [STRING]

Gets or sets the CSS class the menu item should have in addition to the default classes. This is only used if "raw_html" isn't specified.

attributes [HASHREF]

Gets or sets a hashref of HTML attribute name-value pairs that the menu item should have in addition to the attributes which have their own accessor, like "class" and "target". This is only used if "raw_html" isn't specified.

path

Gets or sets the URL that the menu's link goes to. If the link provided is not absolute (does not start with a "/"), then is is treated as relative to it's parent's path, and made absolute.

active [BOOLEAN]

Gets or sets if the menu item is marked as active. Setting this cascades to all of the parents of the menu item.

This is currently unused.

child KEY [, PARAMHASH]

If only a KEY is provided, returns the child with that KEY.

Otherwise, creates or overwrites the child with that key, passing the PARAMHASH to "new" in RT::Interface::Web::Menu. Additionally, the paramhash's "title" defaults to the KEY, and the "sort_order" defaults to the pre-existing child's sort order (if a KEY is being over-written) or the end of the list, if it is a new KEY.

If the paramhash contains a key called menu, that will be used instead of creating a new RT::Interface::Web::Menu.

active_child

Returns the first active child node, or undef is there is none.

delete KEY

Removes the child with the provided KEY.

has_children

Returns true if there are any children on this menu

children

Returns the children of this menu item in sorted order; as an array in array context, or as an array reference in scalar context.

add_after

Called on a child, inserts a new menu item after it and shifts any other menu items at this level to the right.

child by default would insert at the end of the list of children, unless you did manual sort_order calculations.

Takes all the regular arguments to child.

add_before

Called on a child, inserts a new menu item at the child's location and shifts the child and the other menu items at this level to the right.

child by default would insert at the end of the list of children, unless you did manual sort_order calculations.

Takes all the regular arguments to child.

← Back to index