Containers

Migrating from Previous Versions

This chapter documents primarily backwards compatibility breaks made in Zend_Navigation and Zend_View_Helper_Navigation, and should serve to aid in migration from previous versions.

Migrating from versions prior to 1.9

Prior to the 1.9 release, the menu helper (Zend_View_Helper_Navigation_Menu) did not render sub menus correctly. When the onlyActiveBranch was TRUE and the option renderParents FALSE, nothing would be rendered if the deepest active page was at a depth lower than the minDepth option.

In simpler words; if minDepth was set to 1 and the active page was at one of the first level pages, nothing would be rendered, as the following example shows.

Consider the following container setup:

  1. <?php
  2. $container = new Zend_Navigation(array(
  3.     array(
  4.         'label' => 'Home',
  5.         'uri'   => '#'
  6.     ),
  7.     array(
  8.         'label'  => 'Products',
  9.         'uri'    => '#',
  10.         'active' => true,
  11.         'pages'  => array(
  12.             array(
  13.                 'label' => 'Server',
  14.                 'uri'   => '#'
  15.             ),
  16.             array(
  17.                 'label' => 'Studio',
  18.                 'uri'   => '#'
  19.             )
  20.         )
  21.     ),
  22.     array(
  23.         'label' => 'Solutions',
  24.         'uri'   => '#'
  25.     )
  26. ));

The following code is used in a view script:

  1. <?php echo $this->navigation()->menu()->renderMenu($container, array(
  2.     'minDepth'         => 1,
  3.     'onlyActiveBranch' => true,
  4.     'renderParents'    => false
  5. )); ?>

Before release 1.9, the code snippet above would output nothing.

Since release 1.9, the _renderDeepestMenu() method in Zend_View_Helper_Navigation_Menu will accept active pages at one level below minDepth, as long as the page has children.

The same code snippet will now output the following:

  1. <ul class="navigation">
  2.     <li>
  3.         <a href="#">Server</a>
  4.     </li>
  5.     <li>
  6.         <a href="#">Studio</a>
  7.     </li>
  8. </ul>

Containers