我有一个客户端html和javascript应用程序,它使用REST API,返回JSON。现在我登录时有主页面,将配置文件信息存储在javascript对象中。然后系统中的所有其他页面都显示在iFrame中,这样他们就可以访问父页面中的JSON数据,而无需再进行另一次ajax调用。
由于未来的需求,我需要将应用程序移动到Zend Framework,我不确定如何呈现包含iframe的单个视图,然后将所有其他视图加载到其中,而不是实例化新的布局模板,只是加载视图。
我对Zend Framework的了解已经足够了,所以我不是在寻找基本的Zend Framework帮助,只是一个疯狂的用例,为什么是iframe ......我不知道,客户要求。
提前致谢:)
答案 0 :(得分:0)
将您的默认布局设置为iframe中使用的布局(即最小装饰)
; application.ini
resources.layout.layoutPath = APPLICATION_PATH "/layouts/scripts"
resources.layout.layout = "iframe"
; refers to application/layouts/scripts/iframe.phtml
在主页面控制器中,将布局设置为整页版本
public function indexAction() {
$this->_helper->layout->setLayout('full');
// refers to application/layouts/scripts/full.phtml
}
在完整页面布局中,创建iframe并将其命名为
<iframe src="" name="content" height="100" width="200">You need a Frames Capable browser to view this content.</iframe>
在您的主页面视图中,直接指向在iframe中打开的链接
<a href="<?php echo $this->url(array(
'action' => 'some-action'
)) ?>" target="content">Click me</a>