doulizhi1247 2014-04-27 18:59
浏览 30
已采纳

Yii - 覆盖$ content

As far as I noticed seeking across the internet, there's no nice&smooth method for template inheritance in Yii, but I'm wondering if there's a nice method to at least overwrite $content in a template. Basically, I'm trying to avoid something like this:

// Let's say that I have a website with a nice layout and I created a "support" module and in its main theme I want to add a nice heading and some activity status under the $content

// modules/support/templates/main.php

$content = '<div id="someCoolHeader">lorem ipsum</div>'.$content.'<div id="supportAvailability">'.isSuportActive().'</div>';

require_once(CWebApplication::getViewPath().DIRECTORY_SEPARATOR.'main.php');

How should it get done right?

  • 写回答

1条回答 默认 最新

  • duanbipu7601 2014-04-28 02:35
    关注

    There are many ways to templating. Layouts can be customised to your needs very much. Have a look at Yii definitive guide topic. Also this

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥88 实在没有想法,需要个思路
  • ¥15 MATLAB报错输入参数太多
  • ¥15 python中合并修改日期相同的CSV文件并按照修改日期的名字命名文件
  • ¥15 有赏,i卡绘世画不出
  • ¥15 如何用stata画出文献中常见的安慰剂检验图
  • ¥15 c语言链表结构体数据插入
  • ¥40 使用MATLAB解答线性代数问题
  • ¥15 COCOS的问题COCOS的问题
  • ¥15 FPGA-SRIO初始化失败
  • ¥15 MapReduce实现倒排索引失败