zoukankan      html  css  js  c++  java
  • YIi 使用 beginContent() 和 endContent() 设定 Yii 的 layouts

    Yii 的 views/layouts 是用来放置 layouts 的目录,在默认的情况下会有 main.php 和 column1.php 和 column2.php。

    main.php 内容定义了,<head> 以及 page header 和 footer 等。 column1.php 和 column2.php 是使用 main.php 的网页布局,但修改内容的部份。

    例如,我们有个 layout 叫做 mylayout.php:

    <?php $this->beginContent('//layouts/main'); ?>
    <div>
        <?php echo $content ?>
    </div>
    <div class="sidebar">
        <ul>
            <li>option 1</li>
            <li>option 2</li>
        </ul>
    </div>
    <?php $this->endContent() ?>
    (输出$content内容,增加另外的div内容输出)

    beginContent(‘//layouts/main’) 表示以 main 为布局,在  beginContent() 和 endContent() 之间为 content 呈现的修改。 beginContent() 和 endContent() 之外的范围不建议加入 HTML,否则会在 main.php 内容的前面或后面(<html> 标签之前或 </html> 标签之后)。

    在 controller 里可以这样使用:

    public function actionMylayout() {
        $this->layout = 'mylayout';
        $this->render('//site/index');
    }
    转自:http://iteches.com/archives/63580
  • 相关阅读:
    UVA 1660 Cable TV Network
    UVA 1149 Bin Packing
    UVA 1610 Party Games
    UVA 12545 Bits Equalizer
    UVA 11491 Erasing and Winning
    UVA 1611 Crane
    DataTable循环删除行
    SqlBulkCopy使用心得 (大量数据导入)
    JQuery选择器大全
    java学习--GUI3
  • 原文地址:https://www.cnblogs.com/youxin/p/3822636.html
Copyright © 2011-2022 走看看