Menu::display (method)

Last updated: Tue, Oct 31, 2023 1:03 pm
Return to Knowledgebase

Purpose

Location

users/classes/Menu.php

Parameters

# Parameter Data Type Required Description
1 $override = [] Associative Array Yes Associative array with optional parameters to customize the menu

Returns

Data Type Description of Returned Data
other

Example

$menu->display($override)

Further Documentation:

1. Checks if the layout key is set in the $override array and updates the menu's type if the value is either "horizontal," "vertical," or "accordion."
2. If the show_active key is set in the $override array, it adjusts the menu's configuration to display active items based on the given value.
3. If the branding_html key is set in the $override array, it updates the branding HTML of the menu accordingly.
4. Checks if the show_branding key is set in the $override array and, if the provided value is false, hides the branding.
5. Checks if the theme key is set in the $override array and, if the provided value is false, updates the menu's theme accordingly.
6. Generates the HTML for the menu using the generate method and outputs the result.


// replace ID with the ID from the table below for the menu you want to display.
$menu = new Menu(ID);
$menu->display();

// some features can be overridden between instantiation and displaying the menu.
$menu = new Menu(1);
$override = [
"layout"=>"vertical", //horizontal, accordion
"branding_html"=>"

Foo

", //override branding (logo) HTML
"show_branding"=>true, //show/hide branding html on menu
"show_active"=>true, //highlight active menu item
"theme"=>"dark", //override the theme (light, dark)
];
$menu->display($override);

//to force a specific menu on a page, just after init.php use
$menu_override = 2; //where 2 is the menu ID
?>