如何在Zend Framework中切换布局文件? [英] How to switch layout files in Zend Framework?

查看:101
本文介绍了如何在Zend Framework中切换布局文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我确定这是一个简单的单行代码,但是我似乎找不到它.

I'm sure it's a simple one-liner, but I can't seem to find it.

如何为特定操作使用其他布局文件?

How can I use a different layout file for a particular action?

更新:这对我有用,谢谢!

Update: This worked for me, thanks!

// Within controller
$this->_helper->_layout->setLayout('other-layout') //other-layout.phtml

//Within view script
<?php $this->layout()->setLayout('other-layout'); ?>

推荐答案

从控制器内部:

$this->_helper->layout->setLayout('/path/to/your/layout_script');

(通过这些文档)

我应该提一下,该路径是相对于您的布局目录所对应的(默认情况下为application/layouts/scripts/)

I should mention that the path is relative to whatever your layout directory is (by default, it's application/layouts/scripts/)

这篇关于如何在Zend Framework中切换布局文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆