1

i've got my navigation running and all links are working fine. Rendering the Navigation using $this->navigation($nav)->menu() will display an unordered list and all links are working.

Additionally the active link there is working, too. The active element has class="active" as an attribute.

Rendering the same navigation, only as a bradcrumb $this->navigation($nav)->breadcrumbs() doesn't render me anything. This MAY be due to my navigation only being one level deep for now, but imo the first level should still be rendered.

Using super modern die()-debugging i found out that nothing get's rendered because the findActive() of the viewHelper doesn't find an active element and therefore returns an empty string.

Any thoughts on where my error may be located? Any insight will be greatly appreciated. Here's my code so far:

'navigation' => array(
    'default' => array(
        'biete' => array(
            'label' => 'Biete',
            'route' => 'biete',
        ),
        'suche' => array(
            'label' => 'Suche',
            'route' => 'suche',
        ),
        'administration' => array(
            'label' => 'Administration',
            'route' => 'admin'
        ),
        'dashboard' => array(
            'label' => 'Meine Artikel',
            'route' => 'dashboard'
        ),
        'login' => array(
            'label' => 'Anmelden',
            'route' => 'duituser/login'
        ),
        'logout' => array(
            'label' => 'Abmelden',
            'route' => 'duituser/logout'
        )
    ),
),
'service_manager' => array(
    'factories' => array(
        'translator' => 'Zend\I18n\Translator\TranslatorServiceFactory',
        'navigation' => 'Zend\Navigation\Service\DefaultNavigationFactory',
    ),
),

And the view Parts located in my layout.phtml

<?php echo $this->navigation('navigation')->menu(); ?>
<?php echo $this->navigation('navigation')->breadcrumbs(); ?>

Thanks again in advance.

Sam
  • 16,435
  • 6
  • 55
  • 89

3 Answers3

2

I had a play with the Navigation classes/helper - it seems that breadcrumbs are rendered (in the example below) when the 'playground' route is matched. However by adding 'active' => true to my default route means it will always be rendered by the breadcrumb helper.

'navigation' => array(
     'default' => array(
        'test' => array(
            'label' => 'Home',
            'route' => 'test',
            'active' => true,
            'pages' => array(
                'playground' => array(
                    'label' => 'Playground',
                    'route' => 'playground',
                ),
            ),
        ),
    ),
 ),
DrBeza
  • 2,241
  • 1
  • 16
  • 18
  • Thanks Beza, you've actually pointed me into the right direction. The problem was the single-level-navigation. Therefore i had to `setMinDepth(0)` - if u want to u can edit your answer into that direction, otherwise ill post an answer myself tomorrow ;) – Sam Oct 17 '12 at 11:34
  • I did investigate setMinDepth(0) but it had no effect. Trying it just now with 'active' => true on the home route it seems to give the desired effect. – DrBeza Oct 17 '12 at 12:23
  • i didn't need to set active to true at all. The active part get's matched by the routest without any problem. To me it was just the min depth – Sam Oct 17 '12 at 12:32
  • I did edit my answer but I will let you provide an answer as simply calling $this->navigation('navigation')->breadcrumbs()->setMinDepth(0); does not work for me. – DrBeza Oct 17 '12 at 12:38
1

In addition to the answer of DrBeza, here is what helped me. The problem was that the Breadcrumb-Navigation only got rendered once we hit the second level. But you can obviously change that setting by calling the following:

$this->navigation('navigation')->breadcrumbs()->setMinDepth(0);

To me, this is all that was needed. As DrBeza pointed out however in some cases this may not be enough.

Sam
  • 16,435
  • 6
  • 55
  • 89
0

In my case helps only this this:

$this->navigation('navigation')->breadcrumbs()->render('navigation');

The strange is, that it's required only if $this->navigation('navigation')->menu() is called before, because breadcrumbs are not rendered.

Zdenek Machek
  • 1,758
  • 1
  • 20
  • 30