2011-04-08 62 views
9

我正试图从foo访问酒吧的局部视图。简化文件结构:如何在Zend中使用来自不同模块的局部视图?

application/ 
    modules/ 
     foo/ 
      index.phtml 
     bar/ 
      partial.phtml 

而且在的index.html你有下面的代码:

<?php echo $this->partialLoop('../bar/partial.phtml', $this->paginator); 
echo $this->paginator; ?> 

的问题是,你不能真正使用父对象的遍历,因为我得到这个错误:

Requested scripts may not include parent directory traversal ("../", "..\" notation) 

有没有办法将部分视图包含到我的内容页面中? (或者我做错了吗?)提前致谢。

回答

16

你需要通过模块参数:

<?php echo $this->partialLoop('partial.phtml', 'bar', $this->paginator); ?> 
+0

哦,太棒了;非常感谢。假设这对辅助者也是有效的? – levivanzele 2011-04-08 20:09:59

+0

取决于你试图访问什么和如何。看看有关帮助程序或组件的API或完整文档。 – prodigitalson 2011-04-08 20:12:30

7

我已经经历了同样的问题了。 我不得不将一个模块的视图包含到另一个模块的视图中。 我已经通过添加视图控制器内的脚本路径(在此我必须包括其他视图)

$this->view->addScriptPath(APPLICATION_PATH.'/modules/moduleName/views/scripts/actionName'); 

解决了这个问题,然后包括在视图文件中的脚本:

<?php 
    echo $this->render('common-header.phtml'); 
    //Name of the file you want to include 
?> 
相关问题