YII 2.x 模板文件的 beginBlock、beginContent、beginCache

 

echo '-----------beginBlock--------------------- <br />';
$this->beginBlock('block1',  false);
    echo 'beginBlock demo 1 <br />';
$this->endBlock();
echo $this->blocks['block1'];


$this->beginBlock('block2',  true);
    echo 'beginBlock demo 2 <br />';
$this->endBlock();

echo '-----------beginContent--------------------- <br />';
// 渲染内容,传递给文件
$this->beginContent('@app/views/layouts/main.php',  array('param1'=>'param1_value'));
    echo 'beginContent demo1...';
$this->endContent();


echo '-----------beginCache--------------------- <br />';
if($this->beginCache('beginCache1')){
    echo $this->renderDynamic("echo 'beginCache demo1... <br />';");
    $this->endCache();
}

 

posted on 2017-01-06 18:05  周~~  阅读(2415)  评论(0编辑  收藏  举报

导航