Zend_Navigation-Migration.xml 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!-- Reviewed: no -->
  3. <sect1 id="zend.navigation.migration">
  4. <title>Migrating from Previous Versions</title>
  5. <para>
  6. This chapter documents primarily backwards compatibility breaks made in
  7. Zend_Navigation and Zend_View_Helper_Navigation, and should serve to aid
  8. in migration from previous versions.
  9. </para>
  10. <sect2 id="zend.view.navigation.zf7341">
  11. <title>Migrating from versions prior to 1.9</title>
  12. <para>
  13. Prior to the 1.9 release, the menu helper
  14. (<classname>Zend_View_Helper_Navigation_Menu</classname>) did not
  15. render sub menus correctly. When the <code>onlyActiveBranch</code>
  16. was <code>true</code> and the option <code>renderParents</code>
  17. <code>false</code>, nothing would be rendered if the deepest active
  18. page was at a depth lower than the <code>minDepth</code> option.
  19. </para>
  20. <para>
  21. In simpler words; if <code>minDepth</code> was set to <code>1</code>
  22. and the active page was at one of the first level pages, nothing
  23. would be rendered, as the following example shows.
  24. </para>
  25. <para>
  26. Consider the following container setup:
  27. </para>
  28. <programlisting language="php"><![CDATA[
  29. <?php
  30. $container = new Zend_Navigation(array(
  31. array(
  32. 'label' => 'Home',
  33. 'uri' => '#'
  34. ),
  35. array(
  36. 'label' => 'Products',
  37. 'uri' => '#',
  38. 'active' => true,
  39. 'pages' => array(
  40. array(
  41. 'label' => 'Server',
  42. 'uri' => '#'
  43. ),
  44. array(
  45. 'label' => 'Studio',
  46. 'uri' => '#'
  47. )
  48. )
  49. ),
  50. array(
  51. 'label' => 'Solutions',
  52. 'uri' => '#'
  53. )
  54. ));
  55. ]]></programlisting>
  56. <para>
  57. The following code is used in a view script:
  58. </para>
  59. <programlisting language="php"><![CDATA[
  60. <?php echo $this->navigation()->menu()->renderMenu($container, array(
  61. 'minDepth' => 1,
  62. 'onlyActiveBranch' => true,
  63. 'renderParents' => false
  64. )); ?>]]></programlisting>
  65. <para>
  66. Before release 1.9, the code snippet above would output nothing.
  67. </para>
  68. <para>
  69. Since release 1.9, the <code>_renderDeepestMenu()</code> method in
  70. <classname>Zend_View_Helper_Navigation_Menu</classname> will accept
  71. active pages at one level below <code>minDepth</code>, as long as
  72. the page has children.
  73. </para>
  74. <para>
  75. The same code snippet will now output the following:
  76. </para>
  77. <programlisting language="html"><![CDATA[
  78. <ul class="navigation">
  79. <li>
  80. <a href="#">Server</a>
  81. </li>
  82. <li>
  83. <a href="#">Studio</a>
  84. </li>
  85. </ul>]]></programlisting>
  86. </sect2>
  87. </sect1>