首页 > 代码库 > YII 2.x 模板文件的 beginBlock、beginContent、beginCache

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();
}

 

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