yii2-adminlte-asset,yii2-admin integration

1 Install yii2-adminlte-asset, yii2-admin my project version is

yii2-adminlte-asset": "2.6.0"

yii2-admin": "2.8"

composer require mdmsoft/yii2-admin "2.8"

 

composer require dmstr/yii2-adminlte-asset "2.6.0"

2 For adminlte, just copy the files in the template to the background, and the use of adminlte is omitted here.

3 yii2-admin

<?php
$params = array_merge(
    require __DIR__ . '/../../common/config/params.php',
    require __DIR__ . '/../../common/config/params-local.php',
    require __DIR__ . '/params.php',
    require __DIR__ . '/params-local.php'
);

return [
    'id' => 'app-backend',
    'basePath' => dirname(__DIR__),
    'controllerNamespace' => 'backend\controllers',
    'bootstrap' => ['log'],
    'modules' => [
        'admin' => [
            'class' => 'mdm\admin\Module',
//            'layout' => 'left-menu'
        ]
    ],
    'components' => [
        'request' => [
            'csrfParam' => '_csrf-backend',
        ],
        'user' => [
            'identityClass' => 'common\models\UserAdmin',
            'enableAutoLogin' => true,
            'identityCookie' => ['name' => '_identity-backend', 'httpOnly' => true],
        ],
        'session' => [
            // this is the name of the session cookie used for login on the backend
            'name' => 'advanced-backend',
        ],
        'log' => [
            'traceLevel' => YII_DEBUG ? 3 : 0,
            'targets' => [
                [
                    'class' => 'yii\log\FileTarget',
                    'levels' => ['error', 'warning'],
                ],
            ],
        ],
        'errorHandler' => [
            'errorAction' => 'site/error',
        ],

        'urlManager' => [
            'enablePrettyUrl' => true,
            'showScriptName' => false,
            'rules' => [
            ],
        ],
        'authManager' => [
            'class' => 'yii\rbac\DbManager', // use database to manage configuration files
        ],
        'i18n' => [
            'translations' => [
                '*' => [
                    'class' => 'yii\i18n\PhpMessageSource',
                    'fileMap' => [
                    ],
                ],
            ],
        ],
    ],
    'params' => $params,
    'as access' => [
        'class' => 'mdm\admin\components\AccessControl',
        'allowActions' => [
            'site/*',//The node that allows access, you can add it yourself
            'admin/*',//Allow everyone to access the admin node and its child nodes
            '*'
        ]
    ],
];

 In yii2-admin, there may be a problem that the route drop-down display is abnormal, please add jquery-migrate to make the version compatible

4 Use yii2-admin menu

<?php
        use mdm\admin\components\MenuHelper;
        echo dmstr\widgets\Menu::widget([
            'options' => ['class' => 'sidebar-menu tree', 'data-widget'=> 'tree'],
            'items' => MenuHelper::getAssignedMenu(Yii::$app->user->id),
        ]);
        ?>

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324726834&siteId=291194637