CatalystX::Menu::Tree - Generate Catalyst application menus


CatalystX-Menu-Tree documentation  | view source Contained in the CatalystX-Menu-Tree distribution.

Index


NAME

Top

CatalystX::Menu::Tree - Generate Catalyst application menus

SYNOPSIS

Top

 my $tree = CatalystX::Menu::Tree->new(
    context => $c,
    namespaces => [ $c->namespace ],
    filter => sub {
        my ($c, %action) = @_;
        # return the list of k/v pairs that meet criteria
    },
    menupath_attr => 'MenuPath',
    menutitle_attr => 'MenuTitle',
    add_nodes => [
        {
            menupath => '/Bargains',
            menutitle => 'Cheap stuff',
            uri => '/products/cheap',
        },
        {
            menupath => '/Returns',
            menutitle => 'Return a product',
            uri => '/products/returns',
        },
    ],
 );

DESCRIPTION

Top

Builds the tree used by CatalystX::Menu::Suckerfish to construct an HTML UL element for use as a degradable, CSS-styled menu or horizontal navbar.

Catalyst actions with the Private attribute are excluded from the tree.

METHODS

Top

new( %params )

Return an instance of this class.

Params

context

The Catalyst application context (usually $c or $ctx in your controller).

The action attribute that contains the menu tree path to the menu item to be inserted for each action.

The action attribute that contains text describing each action. This text is applied as a "title" attribute to the menu item's HTML container so that a tooltip will be displayed when the pointer hovers over the menu item.

This text can be used anywhere in your application where a description of an action is useful.

namespaces

A reference to an array of action namespaces from which actions with the menupath_attr attribute should be collected.

filter

A reference to a subroutine that takes the Catalyst context and a hash of action name/action object and returns the name/action pairs that meet certain criteria.

add_nodes

A list of hash references containing data defining arbitrary menu items to be merged into the menu tree.

INTERNAL METHODS

Top

_build_tree()

Create and store a reference to a hash containing a tree of menu data.

_get_actions()

Build a hash of Catalyst::Action objects.

AUTHOR

Top

David P.C. Wollmann <converter42@gmail.com>

BUGS

Top

This is brand new code, so use at your own risk.

COPYRIGHT & LICENSE

Top


CatalystX-Menu-Tree documentation  | view source Contained in the CatalystX-Menu-Tree distribution.