如何在 Zend 中使用不同模块的部分视图?

发布于 2024-10-31 19:19:33 字数 562 浏览 2 评论 0原文

我正在尝试从另一个模块 bar 访问 foo 中的部分视图。简化的文件结构:

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)

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

I'm trying to access a partial view in foo from another module bar. Simplified file structure:

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

And in index.html you would have the following code:

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

The problem is that you can't actually use parent traversal, as I get this error:

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

Is there any way to still include the partial view into my content page? (Or am I doing it wrong?) Thanks in advance.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

绮筵 2024-11-07 19:19:33

您需要传递模块参数:

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

You need to pass the module argument:

<?php echo $this->partialLoop('partial.phtml', 'bar', $this->paginator); ?>
π浅易 2024-11-07 19:19:33

我也经历过同样的问题。
我必须将一个模块的视图包含到另一个模块的视图中。
我通过在视图的控制器中添加脚本路径(我必须在其中包含另一个视图)解决了这个问题

$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 
?>

I have gone through the same issue.
I had to include views from one module into another module's views.
I have solved the issue by adding the script path within the controller of the view (in which I had to include the other view)

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

and then included the script within the view file:

<?php 
    echo $this->render('common-header.phtml');
    //Name of the file you want to include 
?>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文