zl程序教程

您现在的位置是:首页 >  其它

当前栏目

phalcon: 视图分层渲染,或包含其他页面

页面 视图 包含 其他 渲染 分层 phalcon
2023-09-14 08:57:52 时间

一:视图分层显现:

比如:在一个页面中,头部、底部固定不变,只有中间部分随操作变换显示。那么可以将中间部分切出来,剩余部分用作固定框架,放入:app/views/layouts目录中,起名为:base.pthml,中间的部分存入相应的目录中去。

接下来,我们看看base.phtml布局

<html>
<title>分层显示</title>
<body>
<p>分层渲染</p>

<?php echo $this->getContent(); ?>


</body>
</html>

中间部分的html不作修改,

 

接下来看代码部分,怎么实现,controller:

public function indexAction()
	{
            //渲染页面,框架部分
            $this->view->setTemplateAfter('common');

            $this->view->pick("index/index");
        


	}

  

 

二:phtml包含其他页面

<?php $this->view->partial("header");?>