如何将 Zend_Navigator 分配给视图?

发布于 2024-10-01 08:00:03 字数 339 浏览 4 评论 0原文

我尝试使用 Zend_Registry 但它没有输出任何内容 然后我在默认模块引导程序中尝试了此操作

public function _initNavigation()
{
    $this->bootstrap('layout');
    $layout = $this->getResource('layout');
    $view = $layout->getView();        

,但它显示'找不到匹配“布局”的资源'。由于我有两个模块,并且我已经在管理模块中使用 Zend_Navigation,所以我不知道如何克服这个问题

I tried using Zend_Registry but it doesn't output anything
then I tried this in my default module bootstrap

public function _initNavigation()
{
    $this->bootstrap('layout');
    $layout = $this->getResource('layout');
    $view = $layout->getView();        

But it says 'Resource matching "layout" not found'. Since I have two modules and I'm already using Zend_Navigation in the admin module, I don't know how to get over with this

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

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

发布评论

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

评论(2

御守 2024-10-08 08:00:04

您首先必须创建布局资源。

我是这样做的:

  $navigation = new Zend_Config_Xml(APPLICATION_PATH.'/configs/navigation.xml','nav');
                $navContainer = new Zend_Navigation($navigation);
                $this->_view->navigation($navContainer);

You first have to create your layout resource.

Here is how i did it:

  $navigation = new Zend_Config_Xml(APPLICATION_PATH.'/configs/navigation.xml','nav');
                $navContainer = new Zend_Navigation($navigation);
                $this->_view->navigation($navContainer);
痴情换悲伤 2024-10-08 08:00:04
$container = new Zend_Navigation(
    Zend_Registry::get('configuration')->navigation
);
$actionController->view->navigation($container);

那应该足够了。

在配置 ini 文件中,您可能有类似以下内容:

;NAVIGATION
navigation.index.label = Index
navigation.index.module = index
navigation.index.controller = index
navigation.index.action = index
navigation.page1.label = Page 1
navigation.page1.module = index
navigation.page1.controller = pages
navigation.page1.action = page-1
$container = new Zend_Navigation(
    Zend_Registry::get('configuration')->navigation
);
$actionController->view->navigation($container);

That should be enough.

In the config ini file you could have something like:

;NAVIGATION
navigation.index.label = Index
navigation.index.module = index
navigation.index.controller = index
navigation.index.action = index
navigation.page1.label = Page 1
navigation.page1.module = index
navigation.page1.controller = pages
navigation.page1.action = page-1
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文