PHP code example of buttflattery / yii2-multimenu
1. Go to this page and download the library: Download buttflattery/yii2-multimenu 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/ */
buttflattery / yii2-multimenu example snippets
echo MultiMenu::widget(
[
'activeCssClass' => 'active',
'items' => Yii::$app->menuhelper->getMenuItems(),
'brandLabel' => 'Left Navigation',
'brandImage' => '/path/to/image/src',// path to image , can be base64encoded image content too
'brandUrl' => 'https://yii2plugins.omaraslam.com',
'activateParents' => true,
'layoutTemplate'=>'{multimenu}{brand}',
'enableIcons'=>true,
'multimenuOptions' => [
'theme' => MultiMenu::THEME_LEFTNAV,
'mobileView' => true,
MultiMenu::THEME_LEFTNAV => [
'position'=>MultiMenu::LEFT_NAV_FIXED,
'slimScroll' => [
'scrollColor' => 'rgba(0,0,0,0.75)'
]
]
]
]
);
use buttflattery\multimenu\MultiMenu;
$items = [
['label' => 'Home', 'url' => ['/site/index']],
['label' => 'About', 'url' => ['/site/about']],
['label' => 'Contact', 'url' => ['/site/contact']],
[
'label' => 'Dropdown',
'url' => 'javascript:void(0)',
'items' => [
['label' => 'Level 2 Dropdown A', 'url' => '#.'],
['label' => 'Level 2 Dropdown B', 'url' => '#.'],
[
'label' => 'Level 3 Dropdown C',
'url'=>'javascript:void(0)'
'items'=>[
[
['label' => 'Level 4 Dropdown A', 'url' => '#.'],
['label' => 'Level 4 Dropdown B', 'url' => '#.'],
['label' => 'Level 4 Dropdown C', 'url' => '#.'],
['label' => 'Level 4 Dropdown D', 'url' => '#.'],
['label' => 'Level 4 Dropdown E', 'url' => '#.'],
]
]
],
],
],
Yii::$app->user->isGuest ? (
['label' => 'Login', 'url' => ['/site/login']]
) : (
'<li>'
. Html::beginForm(['/site/logout'], 'post')
. Html::submitButton(
'Logout (' . Yii::$app->user->identity->username . ')',
['class' => 'btn btn-link logout']
)
. Html::endForm()
. '</li>'
),
];
echo MultiMenu::widget(
[
'activeCssClass' => 'active',
'items' => $items,
'layoutTemplate' => '{multimenu}{brand}',
'enableIcons'=>true,
'brandUrl' => 'https://plugins.omaraslam.com',
'brandLabel'=>'Yii2 Multimenu',
'activateParents' => true,
'multimenuOptions' => [
'theme' => MultiMenu::THEME_BIGDROP,
],
]
);
use buttflattery\multimenu\MultiMenu;
$items = [
['label' => 'Home', 'url' => ['/site/index']],
['label' => 'About', 'url' => ['/site/about']],
['label' => 'Contact', 'url' => ['/site/contact']],
[
'label' => 'Dropdown',
'url' => 'javascript:void(0)',
'items' => [
['label' => 'Level 1 Dropdown A', 'url' => '#'],
['label' => 'Level 1 Dropdown B', 'url' => '#'],
],
],
Yii::$app->user->isGuest ? (
['label' => 'Login', 'url' => ['/site/login']]
) : (
'<li>'
. Html::beginForm(['/site/logout'], 'post')
. Html::submitButton(
'Logout (' . Yii::$app->user->identity->username . ')',
['class' => 'btn btn-link logout']
)
. Html::endForm()
. '</li>'
),
];
echo MultiMenu::widget(
[
'activeCssClass' => 'active',
'items' => $items,
'brandLabel' => 'Left Navigation',
//using base64 encoded image content for brand image
'brandImage' => 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACgAAAAoCAYAAACM/rhtAAAB+0lEQVR4AcyYg5LkUBhG+1X2PdZGaW3btm3btm3bHttWrPomd1r/2Jn/VJ02TpxcH4CQ/dsuazWgzbIdrm9dZVd4pBz4zx2igTaFHrhvjneVXNHCSqIlFEjiwMyyyOBilRgGSqLNF1jnwNQdIvAt48C3IlBmHCiLQHC2zoHDu6zG1iXn6+y62ScxY9AODO6w0pvAqf23oSE4joOfH6OxfMoRnoGUm+de8wykbFt6wZtA07QwtNOqKh3ZbS3Wzz2F+1c/QJY0UCJ/J3kXWJfv7VhxCRRV1jGw7XI+gcO7rEFFRvdYxydwcPsVsC0bQdKScngt4iUTD4Fy/8p7PoHzRu1DclwmgmiqgUXjD3oTKHbAt869qdJ7l98jNTEblPTkXMwetpvnftA0LLHb4X8kiY9Kx6Q+W7wJtG0HR7fdrtYz+x7iya0vkEtUULIzCjC21wY+W/GYXusRH5kGytWTLxgEEhePPwhKYb7EK3BQuxWwTBuUkd3X8goUn6fMHLyTT+DCsQdAEXNzSMeVPAJHdF2DmH8poCREp3uwm7HsGq9J9q69iuunX6EgrwQVObjpBt8z6rdPfvE8kiiyhsvHnomrQx6BxYUyYiNS8f75H1w4/ISepDZLoDhNJ9cdNUquhRsv+6EP9oNH7Iff2A9g8h8CLt1gH0Qf9NMQAFnO60BJFQe0AAAAAElFTkSuQmCC',
'brandUrl' => 'http://omaraslam.com',
'activateParents' => true,
'layoutTemplate'=>'{multimenu}{brand}',
'enableIcons'=>true,
'multimenuOptions' => [
'theme' => MultiMenu::THEME_LEFTNAV,
'mobileView' => true,
MultiMenu::THEME_LEFTNAV => [
'position'=>MultiMenu::LEFT_NAV_FIXED,
'slimScroll' => [
'scrollColor' => 'rgba(0,0,0,0.75)'
]
]
]
]
);
use buttflattery\multimenu\MultiMenu;
$items = [
['label' => 'Home', 'url' => ['/site/index']],
['label' => 'About', 'url' => ['/site/about']],
['label' => 'Contact', 'url' => ['/site/contact']],
[
'label' => 'Dropdown',
'url' => 'javascript:void(0)',
'items' => [
['label' => 'Level 1 Dropdown A', 'url' => '#'],
['label' => 'Level 1 Dropdown B', 'url' => '#'],
],
],
Yii::$app->user->isGuest ? (
['label' => 'Login', 'url' => ['/site/login']]
) : (
'<li>'
. Html::beginForm(['/site/logout'], 'post')
. Html::submitButton(
'Logout (' . Yii::$app->user->identity->username . ')',
['class' => 'btn btn-link logout']
)
. Html::endForm()
. '</li>'
),
];
echo MultiMenu::widget(
[
'activeCssClass' => 'active',
'items' => Yii::$app->menuhelper->getMenuItems('menu_name'),
'activateParents' => true,
'brandLabel' => 'Yii2 Multimenu',
'enableIcons'=>true,
'brandUrl' => 'https://plugins.omaraslam.com',
'layoutTemplate'=>'{multimenu}{brand}',
'multimenuOptions' => [
'theme' => MultiMenu::THEME_DROPUP,
'themeColorFile' => \app\assets\DropUpBisqueRed::class,
'mobileView' => true,
MultiMenu::THEME_DROPUP => [
'transitionEffect' => MultiMenu::ANIMATE_DEFAULT,
],
],
]
);
// @codingStandardsIgnoreStart
namespace app\assets;
use buttflattery\multimenu\assetbundles\bs3\ThemeDropUpAsset;
class DropUpBisqueRed extends ThemeDropUpAsset
{
//@codingStandardsIgnoreEnd
public function init()
{
parent::init();
array_push($this->css, '/css/theme/dropup/bisque-red.css');
}
}
'components' => [
'menuhelper' => [
'class' => 'buttflattery\multimenu\helpers\MenuHelper',
'model' => 'buttflattery\multimenu\models\Menu',
],
'components' => [
'menuhelper' => [
'class' => 'buttflattery\multimenu\helpers\MenuHelper',
'model' => 'app\models\Menus',
'linkField'=>'menu_link',
'labelField'=>'menu_name',
'idField'=>'menu_id',
'parentIdField'=>'menu_parent_id',
],
use buttflattery\multimenu\MultiMenu;
echo MultiMenu::widget(
[
'activeCssClass' => 'active',
'items' => Yii::$app->menuhelper->getMenuItems(),
'layoutTemplate' => '{multimenu}{brand}',
'enableIcons'=>true,
'brandUrl' => 'https://plugins.omaraslam.com',
'brandLabel'=>'Yii2 Multimenu',
'activateParents' => true,
'multimenuOptions' => [
'theme' => MultiMenu::THEME_BIGDROP,
],
]
);
/**
* For use with leftnav `position` option
*/
const LEFT_NAV_FIXED = 'fixed';
const LEFT_NAV_ABSOLUTE = 'absolute';
const LEFT_NAV_DEFAULT = 'default';
/**
* Supported Transition effects by animate.css
* https://daneden.github.io/animate.css/
*/
const ANIMATE_BOUNCE_IN = 'bounceIn';
const ANIMATE_BOUNCE_IN_DOWN = 'bounceInDown';
const ANIMATE_BOUNCE_IN_UP = 'bounceInUp';
const ANIMATE_BOUNCE_IN_LEFT = 'bounceInLeft';
const ANIMATE_BOUNCE_IN_RIGHT = 'bounceInRight';
const ANIMATE_FADE_IN = 'fadeIn';
const ANIMATE_FADE_IN_DOWN = 'fadeInDown';
const ANIMATE_FADE_IN_DOWN_BIG = 'fadeInDownBig';
const ANIMATE_FADE_IN_LEFT = 'fadeInLeft';
const ANIMATE_FADE_IN_LEFT_BIG = 'fadeInLeftBig';
const ANIMATE_FADE_IN_RIGHT = 'fadeInRight';
const ANIMATE_FADE_IN_RIGHT_BIG = 'fadeInRightBig';
const ANIMATE_FLIP = 'flip';
const ANIMATE_FLIP_IN_X = 'flipInX';
const ANIMATE_FLIP_IN_Y = 'flipInY';
const ANIMATE_LITE_SPEED_IN = 'lightSpeedIn';
const ANIMATE_ROTATE_IN = 'rotateIn';
const ANIMATE_ROTATE_IN_DOWN_LEFT = 'rotateInDownLeft';
const ANIMATE_ROTATE_IN_DOWN_RIGHT = 'rotateInDownRight';
const ANIMATE_ROTATE_IN_UP_LEFT = 'rotateInUpLeft';
const ANIMATE_ROTATE_IN_UP_RIGHT = 'rotateInUpRight';
const ANIMATE_SLIDE_IN_UP = 'slideInUp';
const ANIMATE_SLIDE_IN_DOWN = 'slideInDown';
const ANIMATE_SLIDE_IN_LEFT = 'slideInLeft';
const ANIMATE_SLIDE_IN_RIGHT = 'slideInRight';
const ANIMATE_ZOOM_IN = 'zoomIn';
const ANIMATE_ZOOM_IN_UP = 'zoomInUp';
const ANIMATE_ZOOM_IN_DOWN = 'zoomInDow';
const ANIMATE_ZOOM_IN_LEFT = 'zoomInLeft';
const ANIMATE_ZOOM_IN_RIGHT = 'zoomInRight';
/**
* delay types for `transitionDelay` option
* under the menu specific options
*/
const ANIMATE_DEFAULT = '';
const ANIMATE_FAST = 'fast';
const ANIMATE_FASTER = 'faster';
const ANIMATE_SLOW = 'slow';
const ANIMATE_SLOWER = 'slower';
/**
* Waves plugin effects http://fian.my.id/Waves/#examples
* used for the option `wavesEffect`
*/
const WAVES_TYPE_CIRCLE = 'waves-circle';
const WAVES_TYPE_DEFAULT = 'default';
const WAVES_LIGHT = 'waves-light';
const WAVES_RED = 'waves-red';
const WAVES_PINK = 'waves-pink';
const WAVES_PURPLE = 'waves-purple';
const WAVES_DEEP_PURPLE = 'waves-deep-purple';
const WAVES_INDIGO = 'waves-indigo';
const WAVES_BLUE = 'waves-blue';
const WAVES_LIGHT_BLUE = 'waves-light-blue';
const WAVES_CYAN = 'waves-cyan';
const WAVES_TEAL = 'waves-teal';
const WAVES_GREEN = 'waves-green';
const WAVES_LIGHT_GREEN = 'waves-light-green';
const WAVES_LIME = 'waves-lime';
const WAVES_YELLOW = 'waves-yellow';
const WAVES_AMBER = 'waves-amber';
const WAVES_ORANGE = 'waves-orange';
const WAVES_DEEP_ORANGE = 'waves-deep-orange';
const WAVES_BROWN = 'waves-brown';
const WAVES_GREY = 'waves-grey';
const WAVES_BLUE_GREY = 'waves-blue-grey';
const WAVES_BLACK = 'waves-black';
/**
* Themes available used for the `theme` option
* under `multimenuOptions` option
*/
const THEME_BIGDROP = 'bigdrop';
const THEME_LEFTNAV = 'leftnav';
const THEME_DROPUP = 'dropup';
bash
php composer.phar