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条)

报告相同问题?

悬赏问题

  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测