Krang::NavigationNode - a node in the left-navigation menu


  # add a new node to the tree
  my $node = $parent->add_daughter;
  $node->name('Good Stories');
  # add a link under the new node
  my $link1 = $node->add_daughter();
  $link1->name('Find Good Stories');
  # make a node's appearance conditional
  $link1->condition(sub { shift->{asset_perms}{asset_story} ne 'hide' });


Objects of this class represent nodes in the left-navigation menu. Krang::Navigation uses a tree of these nodes to generate the left-nav at run-time. The default tree is setup in Krang::Navigation.

This class is a sub-class of Tree::DAG_Node which provides basic node functionality (add_daughter(), mother(), etc.).


Aside from the inherited Tree::DAG_Node methods the following are methods available:


Get/set the name of the node. This is the textual value displayed in the left-nav.


Get/set the link for the node. Set this to a code-ref for dynamic links.


Set this to a code-ref to control when the node will be shown to users. The code-ref should return 1 if the node is to be shown and 0 otherwise. If a node's condition returns 0 then its children will be hidden as well.

The subroutine will receive the following structure as a single argument:

    { desk  => { pkg('Group')->user_desk_permissions()  },
      asset => { pkg('Group')->user_asset_permissions() },
      admin => { pkg('Group')->user_admin_permissions() },

For too many examples see the default node tree in Krang::Navigation.