开发者

Zend Navigation (breadcrumbs) not displaying

I'm having a problem displaying breadcrumbs with Zend_Navigation.

I have a single controller that takes in a parameter to query out articles from the DB. So, if you point to "articles/view/id/3", it returns the article with an id of 3. The problem I'm having is having breadcrumbs work under this logic. Ideally, when going to "articles/view/id/3" I'd like the breadcrumbs to be: "Articles > Article_Name"

My code renders the navigation and sub navigation alright, it just fails on the breadcrumbs, currently not displaying anything.

Here's my code:

1) Site's navigation in an XML format that looks like:

<?xml version="1.0"?>
<zend-config xmlns:zf="http://framework.zend.com/xml/zend-config-xml/1.0/">
  <nav>
    <articles>
      <label>Articles</label>
      <uri>/</uri>
      <order>1</order>
      <active>1</active>
      <visible>1</visible>
      <pages>
        <article_one>
          <label>Article One</label>
          <uri>/articles/view/id/81e728d9d4c2f636f067f89cc14862c</uri>
          <order>1</order>
          <active>1</active>
          <visible>1</visible>
        </article_one>
      </pages>
    </articles>
  </nav>
</zend-config>

2) Navigation (In the layout):

$config = new Zend_Config_Xml(APPLICATION_PATH . '/configs/navigation.xml', 'nav');
$nav = new Zend_Navigation($config);
$view = new Zend_View();
$view->navigation($nav);
echo $view->navigation()->menu();

3) Breadcrumbs (in the Articles controller):

public function init() {
        $ur开发者_如何学Pythoni = $this->_request->getPathInfo();
        $activeNav = $this->view->navigation()->findByUri($uri);
        $activeNav->class = "selected";
        $activeNav->active = true;
    }

4) Breadcrumbs (In the layout):

//Doesn't display anything[/B]
echo $view->navigation()->breadcrumbs()->setLinkLast(true);

Thanks in advance for any help!


For what parameters URI for?
Where are parameters controller & action?

Your can look here http://framework.zend.com/manual/ru/zend.view.helpers.html Or source code Zend/View/Helper/Navigation/Breadcrumbs.php


Just to point this out, Actualli breadcrumbs work with uri.

The problem is that $this->view->navigation()->findByUri($uri) returns a null object; because even though it is setup in the bootstrap its not seen.

Adding Zend_Registry::set('Zend_Navigation', $navigation); in your bootstrap file should solve the problem.

Cheers


Try adding / to the URL. I had the same problem too.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜