yiioctopus/yii2-adminview

Yii2 开源后台模板。使用非常简单,只需要简单几步就可完成!

Installs: 24

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 2

Forks: 1

Open Issues: 0

Language:CSS

Type:yii2-extension

1.0.0.0 2018-01-09 05:27 UTC

This package is not auto-updated.

Last update: 2024-04-14 02:45:28 UTC


README

Yii2 开源后台模板。使用非常简单,只需要简单几步就可完成!

安装

安装这个扩展的首选方法是通过 composer

可以运行

composer require --prefer-dist yiioctopus/yii2-adminview "*"

也可以添加

"yiioctopus/yii2-adminview": "*"

到你的 composer.json 文件的包含部分。

使用

一旦扩展安装完成,你可以简单的使用它如以下代码:

Setting

Edit @app/assets/AppAsset.php


class AppAsset extends AssetBundle
{
    public $basePath = '@webroot';
    public $baseUrl = '@web';
    public $css = [
        'css/site.css',
    ];
    public $js = [
    ];
    public $depends = [
        'yii\web\YiiAsset',
        'yiioctopus\adminview\AdminviewAsset',
    ];
}

Add 'yiioctopus\adminview\AdminviewAsset' to $depends

Setting layouts

The layouts @app/views/layouts/main.php code:

<?php

/* @var $this \yii\web\View */
/* @var $content string */

use backend\assets\AppAsset;
use yii\helpers\Html;
use yii\helpers\Url;
use yiioctopus\adminview\MainHeader;
use yiioctopus\adminview\MainMenu;

AppAsset::register($this);
?>
<?php $this->beginPage() ?>
<!DOCTYPE html>
<html lang="<?= Yii::$app->language ?>">
<head>
    <meta charset="<?= Yii::$app->charset ?>">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <?= Html::csrfMetaTags() ?>
    <title><?= Html::encode($this->title) ?></title>
    <?php $this->head() ?>
</head>
<body class="theme-blue">
<?php $this->beginBody() ?>

    <?php
        MainHeader::begin([
            'brandName' => 'Yii Octopus',
            //'brandUrl' => 'http://www.hostname.com',
            'userName' => 'yiioctopus',
            'options' => [
                'account' => [
                    'name' => '个人中心',
                    'url' => Url::to(['user/userinfo'],true),
                ],
                'panel' => [
                    [
                        'name' => 'Users',
                        'url' => Url::to(['user/index'],true),
                    ],
                    [
                        'name' => 'Security',
                        'url' => Url::to(['user/security'],true),
                    ],
                ],
                'logout' => [
                    'name' => '退出',
                    'url' => Url::to(['user/logout'],true),
                ],
            ]
        ]);
        
        MainMenu::begin([
            'items' => [
                [
                    'label' => Html::tag('i','',['class'=>'fa fa-fw fa-dashboard']).' Dashboard',
                    'target' => 'dashboard-menu',
                    'items' => [
                        [
                            'label' => 'Login',
                            'url' => ['site/login'],
                        ],
                        [
                            'label' => 'media',
                            'url' => ['site/media'],
                        ],
                    ],
                ],
            ],
            'options' => [
                'active' => [Yii::$app->controller->id .'/'. Yii::$app->controller->action->id],
            ]
        ]);
    ?>

    <div class="content">
        
        <?= $content ?>
        
        <footer>
            <hr>
            <p class="pull-right">Collect from <a href="#" title="首页" target="_blank">首页</a></p>
            <p>© <?= date('Y-m-d') ?> <a href="#" target="_blank">Portnine</a></p>
        </footer>
    </div>

<?php $this->endBody() ?>
</body>
</html>
<?php $this->endPage() ?>

Usage & Document demo

http://octopus.aimeen.com/yii2-adminview