menu() html()

A navbar menu built from a flat id => item list with parent_id: top items with dropdowns.

html()->menu($data = [], $extra = [])

Options

OptionMeaning
$dataId => ['name', 'link', 'parent_id', 'icon']; items without a link are headers.
class, idClasses; id.

Example

Code

return '<div style="min-height:200px;">' . html()->menu([
    11 => ['name' => 'Tools'],
    22 => ['link' => '#blocks', 'name' => 'Blocks editor', 'parent_id' => 11],
    33 => ['link' => '#file_manager', 'name' => 'File manager', 'parent_id' => 11],
    44 => ['name' => 'Administration'],
    55 => ['link' => '#admin', 'name' => 'Admin accounts', 'parent_id' => 44],
    66 => ['link' => '#admin_groups', 'name' => 'Admin groups', 'parent_id' => 44],
    88 => ['name' => 'Users', 'parent_id' => 44],
    99 => ['link' => '#manage_users', 'name' => 'User accounts', 'parent_id' => 88],
    103 => ['name' => 'Content'],
    104 => ['link' => '#static_pages', 'name' => 'Static pages', 'parent_id' => 103],
]) . '</div>';

Bootstrap 3 and 5

Bootstrap 3 navbar dropdowns; Bootstrap 5 dropdown-menu with data-bs-toggle.

See also: html/navbar, html/tree