如何在zendframework2中使用局部 [英] How to use the partial in zendframework2
本文介绍了如何在zendframework2中使用局部的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在ZF1中,我们在layout.phtml文件中使用了类似的部分
In ZF1 we use partial in layout.phtml file something like that
$this->partial('header.phtml', array('vr' => 'zf2'));
我们如何在ZF2中做同样的事情?
How we can do the same in ZF2?
推荐答案
这可以通过
echo $this->partial('layout/header', array('vr' => 'zf2'));
您可以使用
echo $this->vr;
不要忘记在module.config.php文件的view_manager中添加以下行.
don't forget to add following line in your view_manager of module.config.php file.
'layout/header' => __DIR__ . '/../view/layout/header.phtml',
添加后看起来像这样
return array(
'view_manager' => array(
'template_path_stack' => array(
'user' => __DIR__ . '/../view' ,
),
'display_not_found_reason' => true,
'display_exceptions' => true,
'doctype' => 'HTML5',
'not_found_template' => 'error/404',
'exception_template' => 'error/index',
'template_map' => array(
'layout/layout' => __DIR__ . '/../view/layout/layout.phtml',
'layout/header' => __DIR__ . '/../view/layout/header.phtml',
'error/404' => __DIR__ . '/../view/error/404.phtml',
'error/index' => __DIR__ . '/../view/error/index.phtml',
),
),
);
这篇关于如何在zendframework2中使用局部的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文