yii2项目实战-博客管理平台的搭建

40 篇文章 0 订阅

作者:白狼 出处:http://www.manks.top/document/yii2-blog-manage.html 本文版权归作者,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。
相信看了前面的【入门指南】大多数人都已经能够熟练并成功的安装yii2框架了。

上一章节中我们讲述了yii2的配置,并以配置一个单独的全局类为栗子加以补充说明,而且我们也做了项目最基本的时区、语言、缓存和数据库的配置。

我们在【概述】一文中明确指出,将会带大家使用yii2部署一个博客管理平台,但是官方自带的平台似乎有点不合我们心意,相信大多数人的第一感觉就是,这哪里像是管理后台?即使我们凑合凑合愿意接受了,但我们开发出来的产品最终也是交由运营或其他人员进行管理,人家嘴上不说心里也会怀疑我们的技术能力欠缺!

为了给你一个zb的机会,本篇文章的主题,我们使用yii2搭建一款管理后台,以便后续开发过程中养眼之需。

相信不少小伙伴们都应该知道我要借助什么进行搭建后台了,没错,依旧是adminlte。adminlte是个什么东东呢?通俗的说就是一款基于bootstrap的响应模块。yii2-adminlte-asset更是一款基于yii2框架进行开发的后台主题模版,全响应式的哦,出门带手机即可登录进行管理。

我们的项目采用composer进行管理,因此我们首先需要做的便是安装了。

composer require dmstr/yii2-adminlte-asset "2.*"

如果在安装过程中卡住了(报错了),可参考快速入门【安装】一文中的步骤进行安装的yii2框架,该步骤基本可顺利进行。

安装好了之后我们继续进行

拷贝 vendor\dmstr\yii2-adminlte-asset\example-views\yiisoft\yii2-app 目录下面的文件到项目 backend\views, 可直接进行覆盖替换;
默认的yii2-adminlte是蓝色主题,可以按照下面的方式配置主题

1、打开backend\config\main.php 在components中添加assetManager
'components' => [
    'assetManager' => [
        'bundles' => [
            'dmstr\web\AdminLteAsset' => [
                'skin' => 'skin-red',
            ],
        ],
    ],
],
2、打开 backend\views\layouts\main.php,找到body将其class修改如下
<body class="hold-transition <?= \dmstr\helpers\AdminLteHelper::skinClass() ?> sidebar-mini">

受ACF的影响,我们暂时看不出来什么,打开backend\controllers\SiteController.php文件,暂时先屏蔽掉 behaviors 方法的 access 部分,至于是什么意思,后面到了该讲的时候我们会说,现在就先把模版框架搭建好。如此一来,我们刷新下site/index看看,是不是有不同样式的主题了呢?其中配置文件中的skin还有下面的其他样式,随便替换,喜欢哪个用哪个,只需要简单的配置即可。(笔者还没配置过yellow的主题色,赶紧尝试了一把)

"skin-blue",
"skin-black",
"skin-red",
"skin-yellow",
"skin-purple",
"skin-green",
"skin-blue-light",
"skin-black-light",
"skin-red-light",
"skin-yellow-light",
"skin-purple-light",
"skin-green-light"

这不就简单的搭建好了我们的管理后台,样式也都是很ok。如果你需要更多的关于该模版的样式,请浏览器中打开 vendor\almasaeed2010\adminlte\index.html 文件进行参考,涵盖你想要的。
查看原文

基于Yii 框架开发的博客!用于学习YII。 DLFBLOG 1.0 基于Yii 框架开发的博客! Quick start Clone the repo, git clone git://github.com/windsdeng/dlfblog.git, or download the latest release. Bug tracker Have a bug? Please create an issue here on GitHub! Also, when filing please make sure you're familiar with necolas's guidelines. thanks! <3 https://github.com/windsdeng/dlfblog/issues DLFBLOG DEMO http://demo.dlf5.net QQ交流群 1、185207750 Author WindsDeng http://www.dlf5.com https://github.com/windsdeng http://www.weibo.com/windsdeng http://1.t.qq.com/fz-iloveyou Copyright and license The DLFBLOG is free software. It is released under the terms of the following BSD License. Copyright © 2012 by DLF5.NET (http://www.dlf5.net) All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. Neither the name of DLF5.NET nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 标签:dlfblog
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值