dongyiyu3953 2013-10-17 09:49
浏览 21
已采纳

yii模块布局自定义

In yii,I create a module called "admin" and I want to set the module to use the layouts I customized other than the defalult.so I seach some posts and it worked!
this is the post I read:

http://www.yiiframework.com/forum/index.php/topic/24767-module-layout/

after i configured my app as the post,my app worked very well.but now I have some quetions:

  1. the layoutPath
    the post said configure
    $this->layoutPath = Yii::getPathOfAlias('administration.views.layouts');
    the layoutPah variable confuse me very much,it seems this var not be defined in any class.so why it can be called by $this?
  2. /layouts/main
    what is the difference between /layouts/main and //layouts/main when use //layouts/main it will not worked,the app still call the default main layout not mine?
  3. overwriting
    the post also said the public $layout='//layouts/column1'; in controller overwriting the value set in the init() method for the module controller 。 is this tru?
  • 写回答

2条回答 默认 最新

  • douzhao6584 2013-10-17 11:28
    关注
    1. The layoutPath
      The LayoutPath is defined in CWebApplication see details in the wiki So you can se it by using: Yii::app()->layoutPath= Yii::getPathOfAlias('administration.views.layouts');

    2. Answered by PeterM

    3. overwriting See the description of the CController layout attribute:

      The name of the layout to be applied to this controller's views. Defaults to null, meaning the application layout is used. If it is false, no layout will be applied. The module layout will be used if the controller belongs to a module and this layout property is null.

    So you need to set it to null and the module layout will be used. Note: In any action of your controller you can set the layout to null $this->layout=null; so the layout will be null only in this action and not in the others!

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥20 机器学习能否像多层线性模型一样处理嵌套数据
  • ¥20 西门子S7-Graph,S7-300,梯形图
  • ¥50 用易语言http 访问不了网页
  • ¥50 safari浏览器fetch提交数据后数据丢失问题
  • ¥15 matlab不知道怎么改,求解答!!
  • ¥15 永磁直线电机的电流环pi调不出来
  • ¥15 用stata实现聚类的代码
  • ¥15 请问paddlehub能支持移动端开发吗?在Android studio上该如何部署?
  • ¥20 docker里部署springboot项目,访问不到扬声器
  • ¥15 netty整合springboot之后自动重连失效