1. Go to this page and download the library: Download limefamily/yii2-limetheme 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/ */
limefamily / yii2-limetheme example snippets
use yii\web\AssetBundle;
class LimeFamilyAsset extends AssetBundle
{
public $sourcePath = '@vendor/limefamily/static-theme/dist';
public $css = [
'css/limefamily.min.css',
'css/limefamily-skins.min.css',
];
public $js = [
'js/limefamily.min.js'
];
public $depends = [
'yii\web\JqueryAsset',
'yii\bootstrap\BootstrapAsset',
'yii\bootstrap\BootstrapPluginAsset',
];
}
/**
* $pparam 'itmes'. 数组内字段包括(详情去查看组件源码):
*
* - label: string, ui自带的" 图标来填充 默认的是:"fa-pie-chart".
* - visible: boolean, optional, whether this menu item is visible. Defaults to true.
* - linkOptions: array, optional, the HTML attributes of the item's link.
* - options: array, optional, the HTML attributes of the item container (LI).
* - small-icon:当没有字列表时可设置对应的标志 类型 "array"
* - active: boolean, optional, whether the item should be on active state or not.
* - treeviewMenuOptions: array, optional, the HTML options that will passed to the [[Dropdown]] widget.
* - items: array|string, optional, the configuration array for creating a [[Dropdown]] widget,
* or a string representing the dropdown menu. Note that Bootstrap does not support sub-dropdown menus.
*/
$menuItems = array();
if (Yii::$app->user->isGuest) {
$menuItems[] = ['label' => '登录', 'url' => ['/site/login']];
} else {
$menuItems = Yii::$app->user->identity->getAssignedMenu();
$products = Yii::$app->user->identity->getAssignedProducts();
$menuItems[] = ['label' => Yii::$app->user->identity->true_name,
'left-icon' => 'fa-cog',
'items' =>[
['label' => '修改密码', 'url' => ['/site/reset-password']],
['label' => '退出 (' . Yii::$app->user->identity->login_code . ')', 'url' => ['/site/logout']],
]
];
}
echo limefamily\limetheme\widgets\SidebarMenu::widget([
'items' => $menuItems
])