Zend_Navigation 用数组覆盖?

发布于 2024-08-22 11:02:50 字数 585 浏览 8 评论 0原文

我目前通过 XML 文件使用 zend_navigation。

但是,我需要在控制器中覆盖以前的面包屑,使其成为其动态父级。

这可能吗?在我看来,zend_navigation 是相当静态的,并且 zend 文档不断超时。

谢谢,


我已经将:

    public function addAction() {

        $this->view->navigation()->addPage(array(
            'type' => 'uri',
            'label' => 'New page')
        );

放在我的控制器中,但该页面没有显示面包屑栏。

有什么想法吗? $this->navigation() 抛出了一个

Method "navigation" does not exist and was not trapped in __call() 

另外值得注意的是,我的 crumbBar 位于我的布局中,而不是单独的视图中。

I currently use zend_navigation via an XML file.

However I need to overwrite the previous breadcrumb to be its dynamic parent, in the controller.

Is this possible? It seems to me that zend_navigation is fairly static and the zend documentation keeps timing out.

Thanks


I have put:

    public function addAction() {

        $this->view->navigation()->addPage(array(
            'type' => 'uri',
            'label' => 'New page')
        );

in my controller but no crumbbar shows up for that page.

Any ideas? $this->navigation() threw a

Method "navigation" does not exist and was not trapped in __call() 

Also of note that my crumbBar is in my layout and not individual views.

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

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

发布评论

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

评论(2

紧拥背影 2024-08-29 11:02:50

是的,您可以使用数组。

您真正应该做的是创建数组,然后将其输入到 Zend_Navigation 的工厂中来为您创建页面。

不幸的是,我的代码太复杂,无法展示我如何使用它的示例。但我将提供一个简单的示例...

创建导航容器后,您可以向其中添加新页面。

喜欢

$this->navigation()->addPage(array(
   'type' => 'uri',
   'label' => 'New page'));

但你也可以使用 addPages()。这就是我所做的。

我认为您应该等待文档加载回来,然后查看它。事实上这真的很容易。

当你有更具体的问题时,尽管问,然后戳我一下。我经常使用导航,所以对它非常了解。

此外,请查看 freenode 上的#zftalk。那里有很多帮助。

Yes you can use an array.

What you should do really is create your array and then input it into the factory of the Zend_Navigation to create your pages for you.

Unfortunately my code is too complicated to show an example of how I used it. But I'll provide a simple example...

Once you create your navigation container, you can just add new pages to it.

Like

$this->navigation()->addPage(array(
   'type' => 'uri',
   'label' => 'New page'));

But you can also use addPages(). This is what I do.

I think you should just wait for the documentation to load back up for you and then look at that. Its really easy in fact.

When you have a more specific question, just ask that and give me a poke. I've had to use Navigation quite a lot so know it quite well.

Additionally, check out #zftalk on freenode. Theres lots of help on there.

二智少女猫性小仙女 2024-08-29 11:02:50
    // Disable Layout
    $this->view->layout()->disableLayout();     
    $this->_helper->viewRenderer->setNoRender(true);

    // Output XML than HTML
    $this->getResponse()->setHeader('Content-Type', 'text/xml; charset=utf-8');


    $container = new Zend_Navigation();

    // Replace this section with real dynamic data. 
    $pages = array(
        array(
            'label'  => 'Save',
            'action' => 'save',
        ),
        array(
            'label'  => 'Delete',
            'action' => 'delete',
        ),
    );

    // Add pages
    $container->addPages($pages);
    $this->view->navigation($container);

    // Output the data.
    echo $this->view->navigation()->sitemap();

另外,使用 Zend Router 将 site.com/sitemap.xml 重定向到此控制器/功能。

感谢许多帮助我到达这里的开发人员。

    // Disable Layout
    $this->view->layout()->disableLayout();     
    $this->_helper->viewRenderer->setNoRender(true);

    // Output XML than HTML
    $this->getResponse()->setHeader('Content-Type', 'text/xml; charset=utf-8');


    $container = new Zend_Navigation();

    // Replace this section with real dynamic data. 
    $pages = array(
        array(
            'label'  => 'Save',
            'action' => 'save',
        ),
        array(
            'label'  => 'Delete',
            'action' => 'delete',
        ),
    );

    // Add pages
    $container->addPages($pages);
    $this->view->navigation($container);

    // Output the data.
    echo $this->view->navigation()->sitemap();

Additionally uses Zend Router for redirecting site.com/sitemap.xml to this controller/function.

Thank you for many developers who help me to reach here.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文