• yii1.1 项目初始化配置


    在 yii 官网,http://www.yiichina.com/download 中的 git或者直接下载源码包!

    在 deome 中的   blog 中 是这样的 目录:

    这里要说的   默认的  控制器跟视图都在是在 protected 里面的,我们要修改默认的话,

     在  config/main.php中的配置中 要 配置下  参数:

      // 应用组件
    'components'=>array(
       'user'=>array(
          // 启用基于cookie的身份验证
          'allowAutoLogin'=>true,
       ),
    
           'db'=>require(dirname(__FILE__).'/database.php'),
    
       'errorHandler'=>array(
          //使用站点/错误动作显示错误
          'errorAction'=>'site/error',
       ),
       'urlManager'=>array(
          'urlFormat'=>'path',
          'rules'=>array(
             'post/<id:d+>/<title:.*?>'=>'post/view',
             'posts/<tag:.*?>'=>'post/index',
             '<controller:w+>/<action:w+>'=>'<controller>/<action>',
          ),
       ),
       'log'=>array(
          'class'=>'CLogRouter',
          'routes'=>array(
             array(
                'class'=>'CFileLogRoute',
                       'levels'=>'trace', //级别为trace
                       'categories'=>'system.db.*' //只显示关于数据库信息,包括数据库连接,数据库执行语句
             ),
             // uncomment the following to show log messages on web pages
             /*
             array(
                'class'=>'CWebLogRoute',
             ),
             */
          ),
       ),
    ),

     如果用gii 的  也就是 不用默认的 控制器跟 视图的话, 这就要设置了:

    gii新建的什么目录 就要在这里设置空数组的名字.

    'modules'=>array(
        'admin'=>array(),
        'reception'=>array(),
        'test'=>array(),
        //取消注释以启用GII工具
        'gii'=>array(
            'class'=>'system.gii.GiiModule',
            'password'=>'123',
            // If removed, Gii defaults to localhost only. Edit carefully to taste.
            'ipFilters'=>array('127.0.0.1','::1'),
        ),
    
    ),

     用gii生成 modules  控制区都弄好之后呢,重要的就是设置视图目录了

    在 父级 积类,也就是全局控制器中默认是

    class Controller extends CController
    {
       /**
        * @var string the default layout for the controller view. Defaults to 'column1',
        * meaning using a single column layout. See 'protected/views/layouts/column1.php'.
        */
       public $layout='//layouts/main'; // 全局布局目录
       /**
        * @var array context menu items. This property will be assigned to {@link CMenu::items}.
        */
       public $menu=array();
       /**
        * @var array the breadcrumbs of the current page. The value of this property will
        * be assigned to {@link CBreadcrumbs::links}. Please refer to {@link CBreadcrumbs::links}
        * for more details on how to specify this property.
        */
       public $breadcrumbs=array();
    
       public function init()
        {
            Yii::app()->themeManager->setBasePath(getcwd()."/themes");//视图指向对应main.php
        }
    }

    这样就可以 gii生成的 控制器 视图会读取 protected 同级下的 themes 中的 v1.0 下的 views的视图了/ 目录层级要一样!

    新手捣鼓捣鼓,有错误还请指出来哈,谢谢!


    原文在 http://www.lllomh.cn/life/2018-05-18/188.html


  • 相关阅读:
    网络流24题之汽车加油行驶问题
    「CodeChef
    「HNOI 2016」 序列
    「HNOI 2015」实验比较
    「JXOI 2018」 排序问题
    「HNOI 2014」 江南乐
    「HNOI 2015」亚瑟王
    「HNOI 2015」菜肴制作
    「HNOI 2015」落忆枫音
    蓝桥杯 方格分割
  • 原文地址:https://www.cnblogs.com/lllomh/p/14991922.html
Copyright © 2020-2023  润新知