Jifty::Web::Menu.3pm

Langue: en

Version: 2010-06-20 (ubuntu - 24/10/10)

Section: 3 (Bibliothèques de fonctions)

NAME

Jifty::Web::Menu - Handle the API for menu navigation

METHODS

new PARAMHASH

Creates a new Jifty::Web::Menu object. Possible keys in the PARAMHASH are ``label'', ``parent'', ``sort_order'', ``url'', and ``active''. See the subroutines with the respective name below for each option's use.

label [STRING]

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

parent [MENU]

Gets or sets the parent Jifty::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 asked or output, rather than constructing a link, Jifty 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. Gets or set a Jifty::Web::Form::Link object that represents this menu item. If you're looking to do complex ajaxy things with menus, this is likely the option you want.

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 link should have in addition to the default classes. This is only used if ``link'' isn't specified.

render_children_inline [BOOLEAN]

Gets or sets whether children are rendered inline as a menu ``group'' instead of a true submenu. Only used when rendering with YUI for now. Defaults to false.

Note that YUI doesn't support rendering nested menu groups, so having direct parent/children render_children_inline is likely not going to do what you want or expect.

url

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 url, 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.

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 Jifty::Web::Menu. Additionally, the paramhash's ``label'' 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".

active_child

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

delete KEY

Removes the child with the provided KEY.

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.

render_as_menu

Render this menu with HTML markup as multiple dropdowns, suitable for an application's menu

render_as_context_menu

Render this menu with html markup as an inline dropdown menu.

render_as_hierarchical_menu_item

Render an <li> for this item. suitable for use in a regular or contextual menu. Currently renders one level of submenu, if it exists.

render_as_classical_menu

Render this menu with html markup as old classical mason menu. Currently renders one level of submenu, if it exists.

render_as_yui_menubar [PARAMHASH]

Render menubar with YUI menu, suitable for an application's menu. It can support arbitrary levels of submenu. Return this menu item as a Jifty::Web::Form::Link, either the one we were initialized with or a new one made from the ``label'' and ``url''

If there's no ``url'' and no ``link'', renders just the label.