1. Go to this page and download the library: Download symplely/menu 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/ */
symplely / menu example snippets
u = new Async\Menu\Menu;
// The main menu
$menu->add('Home', '');
// Creates a sub menu
$about = $menu->add('About', 'about');
// Creates a another sub menu from the sub menu, passing url and other attributes in key = value pair.
$support = $about->add('Who we are?', ['url' => 'who-we-are', 'class' => 'navbar-item who']);
// Add items to sub menu, passing url and other attributes in key = value pair.
$about->add('What we do?', ['url' => 'what-we-do', 'class' => 'navbar-item what']);
// Item has sub items we append a caret icon to the hyperlink text
$about->append(' <span class="caret"></span>');
// Or just the preset, $default = 'caret'
$about->caret($default);
// Attach HTML attributes to the hyper-link as a key = value array
$about->attributes(['class' => 'link-item', 'target' => '_blank']);
// Or Separately
$about->attributes('data-model', 'nice');
// Or the shorter
$about->addClass('link-item');
$about->addTarget('_blank');
// Add more items to the main menu
$menu->add('Portfolio', 'portfolio');
$menu->add('Contact', 'contact');
// we're only going to hide items with `display` set to **false**
$menu->filter( function($item) {
if ($item->meta('display') === false) {
return false;
}
return true;
});
// Now we can render the menu as various HTML entities:
echo $menu->renderUnordered(['class' => 'some-ul']);
// OR
echo $menu->renderOrdered(['class' => 'some-ol']);
// OR
echo $menu->renderDiv(['class' => 'some-div']);
// For bootstrap users
echo bootstrap_menu($menu);
$menu = new Link;
$menu->add('Home', '/')
$menu->add('About', '/about'));
// Via the `render` method:
echo $menu->render();
// Or just through `__toString`:
echo $menu;