PHP code example of gcworld / menu

1. Go to this page and download the library: Download gcworld/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/ */

    

gcworld / menu example snippets




use GCWorld\Menu\Menu;

$menu = (new Menu())
    ->setTitle('Example application')
    ->setLogo('/images/logo.svg')
    ->setURL('/');

$menu->addLink('dashboard', 'Dashboard', '/dashboard');
$menu->addLink('help', 'Help', '/help', new_win: true, right: true);

echo $menu->returnMenu();

$dropdown = $menu->addDropDown('account', 'Account', right: true);
$panel = $dropdown->addPanel('account-main', 'Account');

$panel->addBlock('profile', 'Profile')
    ->addLink('edit-profile')
    ->setName('Edit profile')
    ->setUrl('/account/profile');

$panel->addBlock('session', 'Session')
    ->addLink('sign-out')
    ->setName('Sign out')
    ->setUrl('/logout')
    ->setClass('danger');

use GCWorld\Menu\Components\DropDownNoticeItem;

$notifications = $menu->addDropDownNotice(
    'notifications',
    'Notifications',
    right: true,
);

$notifications->setEmptyHtml('No new notifications');
$notifications->addItem(
    '<span class="glyphicon glyphicon-info-sign"></span>',
    'Your report is ready.',
    '/reports/latest',
    'report-ready',
);

$item = (new DropDownNoticeItem())
    ->setIcon('<span class="glyphicon glyphicon-user"></span>')
    ->setMessage('A profile needs review.')
    ->setUrl('/profiles/review')
    ->setHoverText('Open profile review');
$item->setData('profile-id', '42');

$notifications->addItemObject($item);

use GCWorld\Menu\Core\Twig as MenuTwig;

MenuTwig::mapAll($twigEnvironment);