PHP code example of adamb / menu-builder
1. Go to this page and download the library: Download adamb/menu-builder library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
adamb / menu-builder example snippets
$navigation = new Menu\Navigation();
// Add links individually
$navigation->addLink('Home', '/', array('link_order' => -1000));
$navigation->addLink('About Me', '/about-me', array('link_order' => 2));
// Add an array of links
$navArray = [
[
'title' => 'My Link',
'uri' => '/my-link-page',
'link_order' => 3
],
[
'title' => 'Has Children',
'uri' => '/child/',
'link_order' => 4
'children' => [
[
'title' => 'Second Child',
'uri' => '/child/second',
'link_order' => 2
],
[
'title' => 'First Child',
'uri' => '/child/first',
'link_order' => 1
],
[
'title' => 'Last Child',
'uri' => '/child/last',
'link_order' => 3
],
]
]
];
$navigation->addLinks($navArray);
$navigation->addLink($title, $uri [, $options = []]);
$navigation->setCurrentURI('/about-me'); // Makes the about me page the current select item in the menu
echo($navigation->render());
echo($navigation->renderBreadcrumb());