NavigationMenu
in package
Renders a menu for the page node structure
If you would like to edit this, it would be much wiser to sub-class it and override the various methods
Table of Contents
Properties
- $close_html : mixed
- HTML to be returned after the last navigation item
- $dropdown_view_name : mixed
- The view name to use for rendering sub-menu dropdowns.
- $open_html : mixed
- HTML to be returned prior to the first navigation item
Methods
- determineClasses() : array<string|int, mixed>
- Determine the classes for the LI for a navigation item
- render() : string
- Return HTML for a mega menu.
- home() : string
- Return HTML for the home page nav item This would typically be a LI
- subMenu() : string
- Return HTML for a drop-down sub menu
Properties
$close_html
HTML to be returned after the last navigation item
protected
static mixed
$close_html
= '</ul>'
$dropdown_view_name
The view name to use for rendering sub-menu dropdowns.
protected
static mixed
$dropdown_view_name
= 'sprout/navigation_dropdown'
Note that if a sub-class overrides the navigation::sub_menu method then this parameter may get ignored.
$open_html
HTML to be returned prior to the first navigation item
protected
static mixed
$open_html
= '<ul id="frankenmenu-list" class="-clearfix">'
Methods
determineClasses()
Determine the classes for the LI for a navigation item
public
static determineClasses(Treenode $node, int $depth, int $index, Treenode $selected_node, array<string|int, mixed> $selected_ancestors, bool $has_children) : array<string|int, mixed>
Parameters
- $node : Treenode
-
The node which is being rendered
- $depth : int
-
The menu depth; 1 for top-level, 2 for a sub menu
- $index : int
-
The position in the menu; 1 for the first item, 2 for the second, etc
- $selected_node : Treenode
-
The page the user is currently looking at
- $selected_ancestors : array<string|int, mixed>
-
All ancestors of the selected node (Treenode::find_ancestors)
- $has_children : bool
-
Does the node have children
Return values
array<string|int, mixed> —Zero or more class names
render()
Return HTML for a mega menu.
public
static render() : string
You shouldn't need to modify or extend this method; If you do then your use case is probably too bespoke for this class.
Return values
string —HTML
home()
Return HTML for the home page nav item This would typically be a LI
protected
static home() : string
Return values
string —HTML
subMenu()
Return HTML for a drop-down sub menu
protected
static subMenu(Treenode $parent_node, array<string|int, mixed> $groups, Treenode $selected_node, array<string|int, mixed> $selected_ancestors) : string
Parameters
- $parent_node : Treenode
-
The node which is being rendered
- $groups : array<string|int, mixed>
-
The groups of items to render, in the format [name => array of Treenode, ...]
- $selected_node : Treenode
-
The page the user is currently looking at
- $selected_ancestors : array<string|int, mixed>
-
All ancestors of the selected node (Treenode::find_ancestors)
Return values
string —HTML