1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420
|
<?xml version="1.0" encoding="UTF-8"?>
<!-- Reviewed: no -->
<sect3 id="zend.view.helpers.initial.navigation">
<title>Navigation Helpers</title>
<para>
The navigation helpers are used for rendering navigational elements
from <link linkend="zend.navigation.containers">Zend_Navigation_Container</link>
instances.
</para>
<para>
There are 5 built-in helpers:
</para>
<itemizedlist>
<listitem>
<para>
<link
linkend="zend.view.helpers.initial.navigation.breadcrumbs">Breadcrumbs</link>,
used for rendering the path to the currently active page.
</para>
</listitem>
<listitem>
<para>
<link linkend="zend.view.helpers.initial.navigation.links">Links</link>,
used for rendering navigational head links (e.g.
<command><link rel="next" href="..." /></command>)
</para>
</listitem>
<listitem>
<para>
<link linkend="zend.view.helpers.initial.navigation.menu">Menu</link>,
used for rendering menus.
</para>
</listitem>
<listitem>
<para>
<link linkend="zend.view.helpers.initial.navigation.sitemap">Sitemap</link>,
used for rendering sitemaps conforming to the <ulink
url="http://www.sitemaps.org/protocol.php">Sitemaps <acronym>XML</acronym>
format</ulink>.
</para>
</listitem>
<listitem>
<para>
<link
linkend="zend.view.helpers.initial.navigation.navigation">Navigation</link>,
used for proxying calls to other navigational helpers.
</para>
</listitem>
</itemizedlist>
<para>
All built-in helpers extend
<classname>Zend_View_Helper_Navigation_HelperAbstract</classname>, which
adds integration with <link linkend="zend.acl">ACL</link> and
<link linkend="zend.translate">translation</link>. The abstract class
implements the interface
<classname>Zend_View_Helper_Navigation_Helper</classname>, which
defines the following methods:
</para>
<itemizedlist>
<listitem>
<para>
<methodname>getContainer()</methodname> and <methodname>setContainer()</methodname>
gets and sets the navigation container the helper should operate on by default, and
<methodname>hasContainer()</methodname> checks if the helper
has container registered.
</para>
</listitem>
<listitem>
<para>
<methodname>getTranslator()</methodname> and
<methodname>setTranslator()</methodname> gets and sets the
translator used for translating labels and titles.
<methodname>getUseTranslator()</methodname> and
<methodname>setUseTranslator()</methodname> controls whether
the translator should be enabled. The method
<methodname>hasTranslator()</methodname> checks if the helper has
a translator registered.
</para>
</listitem>
<listitem>
<para>
<methodname>getAcl()</methodname>, <methodname>setAcl()</methodname>,
<methodname>getRole()</methodname> and <methodname>setRole()</methodname>,
gets and sets <acronym>ACL</acronym> (<classname>Zend_Acl</classname>) instance and
role (<type>String</type> or
<classname>Zend_Acl_Role_Interface</classname>) used for
filtering out pages when rendering. <methodname>getUseAcl()</methodname> and
<methodname>setUseAcl()</methodname> controls whether <acronym>ACL</acronym> should
be enabled. The methods <methodname>hasAcl()</methodname> and
<methodname>hasRole()</methodname> checks if the helper has an
<acronym>ACL</acronym> instance or a role registered.
</para>
</listitem>
<listitem>
<para>
<methodname>__toString()</methodname>, magic method to ensure that
helpers can be rendered by echoing the helper instance directly.
</para>
</listitem>
<listitem>
<para>
<methodname>render()</methodname>, must be implemented by concrete
helpers to do the actual rendering.
</para>
</listitem>
</itemizedlist>
<para>
In addition to the method stubs from the interface, the abstract
class also implements the following methods:
</para>
<itemizedlist>
<listitem>
<para>
<methodname>getIndent()</methodname> and <methodname>setIndent()</methodname>
gets and sets indentation. The setter accepts a <type>String</type> or an
<type>Integer</type>. In the case of an <type>Integer</type>, the helper will use
the given number of spaces for indentation. I.e.,
<methodname>setIndent(4)</methodname> means 4 initial spaces of
indentation. Indentation can be specified for all helpers
except the Sitemap helper.
</para>
</listitem>
<listitem>
<para>
<methodname>getMinDepth()</methodname> and <methodname>setMinDepth()</methodname>
gets and sets the minimum depth a page must have to be included by the helper.
Setting <constant>NULL</constant> means no minimum depth.
</para>
</listitem>
<listitem>
<para>
<methodname>getMaxDepth()</methodname> and <methodname>setMaxDepth()</methodname>
gets and sets the maximum depth a page can have to be included by the helper.
Setting <constant>NULL</constant> means no maximum depth.
</para>
</listitem>
<listitem>
<para>
<methodname>getRenderInvisible()</methodname> and
<methodname>setRenderInvisible()</methodname> gets and sets whether to
render items that have been marked as invisible or not.
</para>
</listitem>
<listitem>
<para>
<methodname>__call()</methodname> is used for proxying calls to the
container registered in the helper, which means you can
call methods on a helper as if it was a container. See <link
linkend="zend.view.helpers.initial.navigation.proxy.example">example</link>
below.
</para>
</listitem>
<listitem>
<para>
<methodname>findActive($container, $minDepth, $maxDepth)</methodname>
is used for finding the deepest active page in the given
container. If depths are not given, the method will use
the values retrieved from <methodname>getMinDepth()</methodname> and
<methodname>getMaxDepth()</methodname>. The deepest active page must
be between <varname>$minDepth</varname> and <varname>$maxDepth</varname>
inclusively. Returns an array containing a reference to the
found page instance and the depth at which the page was
found.
</para>
</listitem>
<listitem>
<para>
<methodname>htmlify()</methodname> renders an <emphasis>'a'</emphasis>
<acronym>HTML</acronym> element from a <classname>Zend_Navigation_Page</classname>
instance.
</para>
</listitem>
<listitem>
<para>
<methodname>accept()</methodname> is used for determining if a page
should be accepted when iterating containers. This method
checks for page visibility and verifies that the helper's
role is allowed access to the page's resource and privilege.
</para>
</listitem>
<listitem>
<para>
The static method <methodname>setDefaultAcl()</methodname> is used for setting
a default <acronym>ACL</acronym> object that will be used by helpers.
</para>
</listitem>
<listitem>
<para>
The static method <methodname>setDefaultRole()</methodname> is used for setting
a default <acronym>ACL</acronym> that will be used by helpers
</para>
</listitem>
</itemizedlist>
<para>
If a navigation container is not explicitly set in a helper using
<command>$helper->setContainer($nav)</command>, the helper will look
for a container instance with the key <classname>Zend_Navigation</classname> in
<link linkend="zend.registry">the registry</link>.
If a container is not explicitly set or found in the registry, the
helper will create an empty <classname>Zend_Navigation</classname>
container when calling <command>$helper->getContainer()</command>.
</para>
<example id="zend.view.helpers.initial.navigation.proxy.example">
<title>Proxying calls to the navigation container</title>
<para>
Navigation view helpers use the magic method <methodname>__call()</methodname>
to proxy method calls to the navigation container that is
registered in the view helper.
</para>
<programlisting language="php"><![CDATA[
$this->navigation()->addPage(array(
'type' => 'uri',
'label' => 'New page'));
]]></programlisting>
<para>
The call above will add a page to the container in the
<classname>Navigation</classname> helper.
</para>
</example>
<sect4 id="zend.view.helpers.initial.navigation.i18n">
<title>Translation of labels and titles</title>
<para>
The navigation helpers support translation of page labels and titles.
You can set a translator of type <classname>Zend_Translate</classname>
or <classname>Zend_Translate_Adapter</classname> in the helper using
<command>$helper->setTranslator($translator)</command>, or like with other
I18n-enabled components; by adding the translator to
<link linkend="zend.registry">the registry</link> by using the key
<classname>Zend_Translate</classname>.
</para>
<para>
If you want to disable translation, use
<command>$helper->setUseTranslator(false)</command>.
</para>
<para>
The
<link linkend="zend.view.helpers.initial.navigation.navigation">proxy
helper</link> will inject its own translator to the helper it
proxies to if the proxied helper doesn't already have a translator.
</para>
<note>
<para>
There is no translation in the sitemap helper, since there
are no page labels or titles involved in an <acronym>XML</acronym> sitemap.
</para>
</note>
</sect4>
<sect4 id="zend.view.helpers.initial.navigation.acl">
<title>Integration with ACL</title>
<para>
All navigational view helpers support <acronym>ACL</acronym> inherently from the
class <classname>Zend_View_Helper_Navigation_HelperAbstract</classname>.
A <classname>Zend_Acl</classname> object can be assigned to
a helper instance with <code>$helper->setAcl($acl)</code>, and role
with <code>$helper->setRole('member')</code> or
<code>$helper->setRole(new Zend_Acl_Role('member'))</code> . If <acronym>ACL</acronym>
is used in the helper, the role in the helper must be allowed by
the <acronym>ACL</acronym> to access a page's <code>resource</code> and/or have the
page's <code>privilege</code> for the page to be included when
rendering.
</para>
<para>
If a page is not accepted by <acronym>ACL</acronym>, any descendant page will also
be excluded from rendering.
</para>
<para>
The
<link linkend="zend.view.helpers.initial.navigation.navigation">proxy
helper</link> will inject its own <acronym>ACL</acronym> and role to the helper it
proxies to if the proxied helper doesn't already have any.
</para>
<para>
The examples below all show how <acronym>ACL</acronym> affects rendering.
</para>
</sect4>
<sect4 id="zend.view.helpers.initial.navigation.setup">
<title>Navigation setup used in examples</title>
<para>
This example shows the setup of a navigation container for a
fictional software company.
</para>
<para>
Notes on the setup:
</para>
<itemizedlist>
<listitem>
<para>
The domain for the site is <code>www.example.com</code>.
</para>
</listitem>
<listitem>
<para>
Interesting page properties are marked with a comment.
</para>
</listitem>
<listitem>
<para>
Unless otherwise is stated in other examples, the user
is requesting the <acronym>URL</acronym>
<code>http://www.example.com/products/server/faq/</code>,
which translates to the page labeled <constant>FAQ</constant>
under <code>Foo Server</code>.
</para>
</listitem>
<listitem>
<para>
The assumed <acronym>ACL</acronym> and router setup is shown below the
container setup.
</para>
</listitem>
</itemizedlist>
<programlisting language="php"><![CDATA[
/*
* Navigation container (config/array)
* Each element in the array will be passed to
* Zend_Navigation_Page::factory() when constructing
* the navigation container below.
*/
$pages = array(
array(
'label' => 'Home',
'title' => 'Go Home',
'module' => 'default',
'controller' => 'index',
'action' => 'index',
'order' => -100 // make sure home is the first page
),
array(
'label' => 'Special offer this week only!',
'module' => 'store',
'controller' => 'offer',
'action' => 'amazing',
'visible' => false // not visible
),
array(
'label' => 'Products',
'module' => 'products',
'controller' => 'index',
'action' => 'index',
'pages' => array(
array(
'label' => 'Foo Server',
'module' => 'products',
'controller' => 'server',
'action' => 'index',
'pages' => array(
array(
'label' => 'FAQ',
'module' => 'products',
'controller' => 'server',
'action' => 'faq',
'rel' => array(
'canonical' => 'http://www.example.com/?page=faq',
'alternate' => array(
'module' => 'products',
'controller' => 'server',
'action' => 'faq',
'params' => array('format' => 'xml')
)
)
),
array(
'label' => 'Editions',
'module' => 'products',
'controller' => 'server',
'action' => 'editions'
),
array(
'label' => 'System Requirements',
'module' => 'products',
'controller' => 'server',
'action' => 'requirements'
)
)
),
array(
'label' => 'Foo Studio',
'module' => 'products',
'controller' => 'studio',
'action' => 'index',
'pages' => array(
array(
'label' => 'Customer Stories',
'module' => 'products',
'controller' => 'studio',
'action' => 'customers'
),
array(
'label' => 'Support',
'module' => 'prodcts',
'controller' => 'studio',
'action' => 'support'
)
)
)
)
),
array(
'label' => 'Company',
'title' => 'About us',
'module' => 'company',
'controller' => 'about',
'action' => 'index',
'pages' => array(
array(
'label' => 'Investor Relations',
'module' => 'company',
'controller' => 'about',
'action' => 'investors'
),
array(
'label' => 'News',
'class' => 'rss', // class
'module' => 'company',
'controller' => 'news',
'action' => 'index',
'pages' => array(
array(
'label' => 'Press Releases',
'module' => 'company',
'controller' => 'news',
'action' => 'press'
),
array(
'label' => 'Archive',
'route' => 'archive', // route
'module' => 'company',
'controller' => 'news',
'action' => 'archive'
)
)
)
)
),
array(
'label' => 'Community',
'module' => 'community',
'controller' => 'index',
'action' => 'index',
'pages' => array(
array(
'label' => 'My Account',
'module' => 'community',
'controller' => 'account',
'action' => 'index',
'resource' => 'mvc:community.account' // resource
),
array(
'label' => 'Forums',
'uri' => 'http://forums.example.com/',
'class' => 'external' // class
)
)
),
array(
'label' => 'Administration',
'module' => 'admin',
'controller' => 'index',
'action' => 'index',
'resource' => 'mvc:admin', // resource
'pages' => array(
array(
'label' => 'Write new article',
'module' => 'admin',
'controller' => 'post',
'aciton' => 'write'
)
)
)
);
// Create container from array
$container = new Zend_Navigation($pages);
// Store the container in the proxy helper:
$view->getHelper('navigation')->setContainer($container);
// ...or simply:
$view->navigation($container);
// ...or store it in the reigstry:
Zend_Registry::set('Zend_Navigation', $container);
]]></programlisting>
<para>
In addition to the container above, the following setup is assumed:
</para>
<programlisting language="php"><![CDATA[
// Setup router (default routes and 'archive' route):
$front = Zend_Controller_Front::getInstance();
$router = $front->getRouter();
$router->addDefaultRoutes();
$router->addRoute(
'archive',
new Zend_Controller_Router_Route(
'/archive/:year',
array(
'module' => 'company',
'controller' => 'news',
'action' => 'archive',
'year' => (int) date('Y') - 1
),
array('year' => '\d+')
)
);
// Setup ACL:
$acl = new Zend_Acl();
$acl->addRole(new Zend_Acl_Role('member'));
$acl->addRole(new Zend_Acl_Role('admin'));
$acl->add(new Zend_Acl_Resource('mvc:admin'));
$acl->add(new Zend_Acl_Resource('mvc:community.account'));
$acl->allow('member', 'mvc:community.account');
$acl->allow('admin', null);
// Store ACL and role in the proxy helper:
$view->navigation()->setAcl($acl)->setRole('member');
// ...or set default ACL and role statically:
Zend_View_Helper_Navigation_HelperAbstract::setDefaultAcl($acl);
Zend_View_Helper_Navigation_HelperAbstract::setDefaultRole('member');
]]></programlisting>
</sect4>
<sect4 id="zend.view.helpers.initial.navigation.breadcrumbs">
<title>Breadcrumbs Helper</title>
<para>
Breadcrumbs are used for indicating where in a sitemap
a user is currently browsing, and are typically rendered
like this: "You are here: Home > Products > FantasticProduct 1.0".
The breadcrumbs helper follows the guidelines from <ulink
url="http://developer.yahoo.com/ypatterns/pattern.php?pattern=breadcrumbs">Breadcrumbs
Pattern - Yahoo! Design Pattern Library</ulink>,
and allows simple customization (minimum/maximum depth, indentation,
separator, and whether the last element should be linked), or
rendering using a partial view script.
</para>
<para>
The Breadcrumbs helper works like this; it finds the deepest active
page in a navigation container, and renders an upwards path to
the root. For <acronym>MVC</acronym> pages, the "activeness" of a page is
determined by inspecting the request object, as stated in the
section on <link linkend="zend.navigation.pages.mvc">Zend_Navigation_Page_Mvc</link>.
</para>
<para>
The helper sets the <code>minDepth</code> property to 1 by default,
meaning breadcrumbs will not be rendered if the deepest active page
is a root page. If <code>maxDepth</code> is specified, the helper
will stop rendering when at the specified depth (e.g. stop at level
2 even if the deepest active page is on level 3).
</para>
<para>
Methods in the breadcrumbs helper:
</para>
<itemizedlist>
<listitem>
<para>
<code>{get|set}Separator()</code> gets/sets separator
string that is used between breadcrumbs. Defualt is
<code>' &gt; '</code>.
</para>
</listitem>
<listitem>
<para>
<code>{get|set}LinkLast()</code> gets/sets whether the
last breadcrumb should be rendered as an anchor or not.
Default is <constant>FALSE</constant>.
</para>
</listitem>
<listitem>
<para>
<code>{get|set}Partial()</code> gets/sets a partial view
script that should be used for rendering breadcrumbs.
If a partial view script is set, the helper's
<methodname>render()</methodname> method will use the
<methodname>renderPartial()</methodname> method. If no partial is
set, the <methodname>renderStraight()</methodname> method is used.
The helper expects the partial to be a <type>String</type>
or an <type>Array</type> with two elements. If the partial
is a <type>String</type>, it denotes the name of the partial
script to use. If it is an <type>Array</type>, the first
element will be used as the name of the partial view
script, and the second element is the module where the
script is found.
</para>
</listitem>
<listitem>
<para>
<methodname>renderStraight()</methodname> is the default render
method.
</para>
</listitem>
<listitem>
<para>
<methodname>renderPartial()</methodname> is used for rendering
using a partial view script.
</para>
</listitem>
</itemizedlist>
<example id="zend.view.helpers.initial.navigation.breadcrumbs.example1">
<title>Rendering breadcrumbs</title>
<para>
This example shows how to render breadcrumbs with default
settings.
</para>
<programlisting language="php"><![CDATA[
In a view script or layout:
<?php echo $this->navigation()->breadcrumbs(); ?>
The two calls above take advantage of the magic __toString() method,
and are equivalent to:
<?php echo $this->navigation()->breadcrumbs()->render(); ?>
Output:
<a href="/products">Products</a> > <a href="/products/server">Foo Server</a> > FAQ
]]></programlisting>
</example>
<example id="zend.view.helpers.initial.navigation.breadcrumbs.example2">
<title>Specifying indentation</title>
<para>
This example shows how to render breadcrumbs with initial
indentation.
</para>
<programlisting language="php"><![CDATA[
Rendering with 8 spaces indentation:
<?php echo $this->navigation()->breadcrumbs()->setIndent(8);?>
Output:
<a href="/products">Products</a> > <a href="/products/server">Foo Server</a> > FAQ
]]></programlisting>
</example>
<example id="zend.view.helpers.initial.navigation.breadcrumbs.example3">
<title>Customize breadcrumbs output</title>
<para>
This example shows how to customze breadcrumbs output by
specifying various options.
</para>
<programlisting language="php"><![CDATA[
In a view script or layout:
<?php
echo $this->navigation()
->breadcrumbs()
->setLinkLast(true) // link last page
->setMaxDepth(1) // stop at level 1
->setSeparator(' ▶' . PHP_EOL); // cool separator with newline
?>
Output:
<a href="/products">Products</a> ▶
<a href="/products/server">Foo Server</a>
/////////////////////////////////////////////////////
Setting minimum depth required to render breadcrumbs:
<?php
$this->navigation()->breadcrumbs()->setMinDepth(10);
echo $this->navigation()->breadcrumbs();
?>
Output:
Nothing, because the deepest active page is not at level 10 or deeper.
]]></programlisting>
</example>
<example id="zend.view.helpers.initial.navigation.breadcrumbs.example4">
<title>Rendering breadcrumbs using a partial view script</title>
<para>
This example shows how to render customized breadcrumbs using
a partial vew script. By calling <methodname>setPartial()</methodname>,
you can specify a partial view script that will be used
when calling <methodname>render()</methodname>. When a partial is specified,
the <methodname>renderPartial()</methodname> method will be called. This
method will find the deepest active page and pass an array
of pages that leads to the active page to the partial view
script.
</para>
<para>
In a layout:
</para>
<programlisting language="php"><![CDATA[
$partial = ;
echo $this->navigation()->breadcrumbs()
->setPartial(array('breadcrumbs.phtml', 'default'));
]]></programlisting>
<para>
Contents of
<code>application/modules/default/views/breadcrumbs.phtml</code>:
</para>
<programlisting language="php"><![CDATA[
echo implode(', ', array_map(
create_function('$a', 'return $a->getLabel();'),
$this->pages));
]]></programlisting>
<para>
Output:
</para>
<programlisting language="php"><![CDATA[
Products, Foo Server, FAQ
]]></programlisting>
</example>
</sect4>
<sect4 id="zend.view.helpers.initial.navigation.links">
<title>Links Helper</title>
<para>
The links helper is used for rendering <acronym>HTML</acronym> <constant>LINK</constant>
elements. Links are used for describing document relationships
of the currently active page. Read more about links and link
types at <ulink url="http://www.w3.org/TR/html4/struct/links.html#h-12.3">Document
relationships: the LINK element (HTML4 W3C Rec.)</ulink>
and <ulink
url="http://www.w3.org/TR/html4/types.html#h-6.12">Link types (HTML4 W3C
Rec.)</ulink> in the <acronym>HTML</acronym>4 W3C Recommendation.
</para>
<para>
There are two types of relations; forward and reverse, indicated
by the keyords <code>'rel'</code> and <code>'rev'</code>. Most
methods in the helper will take a <varname>$rel</varname> param, which
must be either <code>'rel'</code> or <code>'rev'</code>. Most
methods also take a <varname>$type</varname> param, which is used
for specifying the link type (e.g. alternate, start, next, prev,
chapter, etc).
</para>
<para>
Relationships can be added to page objects manually, or found
by traversing the container registered in the helper. The method
<methodname>findRelation($page, $rel, $type)</methodname> will first try
to find the given <varname>$rel</varname> of <varname>$type</varname> from
the <varname>$page</varname> by calling <code>$page->findRel($type)</code>
or <code>$page->findRel($type)</code>. If the <varname>$page</varname>
has a relation that can be converted to a page instance, that
relation will be used. If the <varname>$page</varname> instance doesn't
have the specified <varname>$type</varname>, the helper will look for
a method in the helper named <code>search$rel$type</code> (e.g.
<methodname>searchRelNext()</methodname> or
<methodname>searchRevAlternate()</methodname>).
If such a method exists, it will be used for determining the
<varname>$page</varname>'s relation by traversing the container.
</para>
<para>
Not all relations can be determined by traversing the container.
These are the relations that will be found by searching:
</para>
<itemizedlist>
<listitem>
<para>
<methodname>searchRelStart()</methodname>, forward 'start'
relation: the first page in the container.
</para>
</listitem>
<listitem>
<para>
<methodname>searchRelNext()</methodname>, forward 'next'
relation; finds the next page in the container, i.e.
the page after the active page.
</para>
</listitem>
<listitem>
<para>
<methodname>searchRelPrev()</methodname>, forward 'prev'
relation; finds the previous page, i.e. the page before
the active page.
</para>
</listitem>
<listitem>
<para>
<methodname>searchRelChapter()</methodname>, forward 'chapter'
relations; finds all pages on level 0 except the 'start'
relation or the active page if it's on level 0.
</para>
</listitem>
<listitem>
<para>
<methodname>searchRelSection()</methodname>, forward 'section'
relations; finds all child pages of the active page if
the active page is on level 0 (a 'chapter').
</para>
</listitem>
<listitem>
<para>
<methodname>searchRelSubsection()</methodname>, forward 'subsection'
relations; finds all child pages of the active page if
the active pages is on level 1 (a 'section').
</para>
</listitem>
<listitem>
<para>
<methodname>searchRevSection()</methodname>, reverse 'section'
relation; finds the parent of the active page if the
active page is on level 1 (a 'section').
</para>
</listitem>
<listitem>
<para>
<methodname>searchRevSubsection()</methodname>, reverse 'subsection'
relation; finds the parent of the active page if the
active page is on level 2 (a 'subsection').
</para>
</listitem>
</itemizedlist>
<note>
<para>
When looking for relations in the page instance
(<code>$page->getRel($type)</code> or
<code>$page->getRev($type)</code>), the helper accepts the
values of type <type>String</type>, <type>Array</type>,
<classname>Zend_Config</classname>, or
<classname>Zend_Navigation_Page</classname>. If a string
is found, it will be converted to a
<classname>Zend_Navigation_Page_Uri</classname>. If an array
or a config is found, it will be converted to one or several
page instances. If the first key of the array/config is numeric,
it will be considered to contain several pages, and each
element will be passed to the
<link linkend="zend.navigation.pages.factory">page factory</link>.
If the first key is not numeric, the array/config will be
passed to the page factory directly, and a single page will
be returned.
</para>
</note>
<para>
The helper also supports magic methods for finding relations.
E.g. to find forward alternate relations, call
<code>$helper->findRelAlternate($page)</code>, and to find
reverse section relations, call
<code>$helper->findRevSection($page)</code>. Those calls correspond
to <code>$helper->findRelation($page, 'rel', 'alternate');</code>
and <code>$helper->findRelation($page, 'rev', 'section');</code>
respectively.
</para>
<para>
To customize which relations should be rendered, the helper
uses a render flag. The render flag is an integer value, and will be
used in a
<ulink url="http://php.net/manual/en/language.operators.bitwise.php">bitwse
<code>and</code> (<code>&</code>) operation</ulink> against the
helper's render constants to determine if the relation that belongs
to the render constant should be rendered.
</para>
<para>
See the
<link linkend="zend.view.helpers.initial.navigation.links.example3">example
below</link> for more information.
</para>
<itemizedlist>
<listitem>
<para>
<constant>Zend_View_Helper_Navigation_Links::RENDER_ALTERNATE</constant>
</para>
</listitem>
<listitem>
<para>
<constant>Zend_View_Helper_Navigation_Links::RENDER_STYLESHEET</constant>
</para>
</listitem>
<listitem>
<para>
<constant>Zend_View_Helper_Navigation_Links::RENDER_START</constant>
</para>
</listitem>
<listitem>
<para>
<constant>Zend_View_Helper_Navigation_Links::RENDER_NEXT</constant>
</para>
</listitem>
<listitem>
<para>
<constant>Zend_View_Helper_Navigation_Links::RENDER_PREV</constant>
</para>
</listitem>
<listitem>
<para>
<constant>Zend_View_Helper_Navigation_Links::RENDER_CONTENTS</constant>
</para>
</listitem>
<listitem>
<para>
<constant>Zend_View_Helper_Navigation_Links::RENDER_INDEX</constant>
</para>
</listitem>
<listitem>
<para>
<constant>Zend_View_Helper_Navigation_Links::RENDER_GLOSSARY</constant>
</para>
</listitem>
<listitem>
<para>
<constant>Zend_View_Helper_Navigation_Links::RENDER_COPYRIGHT</constant>
</para>
</listitem>
<listitem>
<para>
<constant>Zend_View_Helper_Navigation_Links::RENDER_CHAPTER</constant>
</para>
</listitem>
<listitem>
<para>
<constant>Zend_View_Helper_Navigation_Links::RENDER_SECTION</constant>
</para>
</listitem>
<listitem>
<para>
<constant>Zend_View_Helper_Navigation_Links::RENDER_SUBSECTION</constant>
</para>
</listitem>
<listitem>
<para>
<constant>Zend_View_Helper_Navigation_Links::RENDER_APPENDIX</constant>
</para>
</listitem>
<listitem>
<para>
<constant>Zend_View_Helper_Navigation_Links::RENDER_HELP</constant>
</para>
</listitem>
<listitem>
<para>
<constant>Zend_View_Helper_Navigation_Links::RENDER_BOOKMARK</constant>
</para>
</listitem>
<listitem>
<para>
<constant>Zend_View_Helper_Navigation_Links::RENDER_CUSTOM</constant>
</para>
</listitem>
<listitem>
<para>
<constant>Zend_View_Helper_Navigation_Links::RENDER_ALL</constant>
</para>
</listitem>
</itemizedlist>
<para>
The constants from <constant>RENDER_ALTERNATE</constant> to
<constant>RENDER_BOOKMARK</constant> denote standard <acronym>HTML</acronym> link types.
<constant>RENDER_CUSTOM</constant> denotes non-standard relations that
specified in pages. <constant>RENDER_ALL</constant> denotes standard and
non-standard relations.
</para>
<para>
Methods in the links helper:
</para>
<itemizedlist>
<listitem>
<para>
<code>{get|set}RenderFlag()</code> gets/sets the render
flag. Default is <constant>RENDER_ALL</constant>. See examples
below on how to set the render flag.
</para>
</listitem>
<listitem>
<para>
<methodname>findAllRelations()</methodname> finds all relations of
all types for a given page.
</para>
</listitem>
<listitem>
<para>
<methodname>findRelation()</methodname> finds all relations of a given
type from a given page.
</para>
</listitem>
<listitem>
<para>
<code>searchRel{Start|Next|Prev|Chapter|Section|Subsection}()</code>
traverses a container to find forward relations to
the start page, the next page, the previous page,
chapters, sections, and subsections.
</para>
</listitem>
<listitem>
<para>
<code>searchRev{Section|Subsection}()</code> traverses
a container to find reverse relations to sections or
subsections.
</para>
</listitem>
<listitem>
<para>
<methodname>renderLink()</methodname> renders a single <code>link</code>
element.
</para>
</listitem>
</itemizedlist>
<example id="zend.view.helpers.initial.navigation.links.example1">
<title>Specify relations in pages</title>
<para>
This example shows how to specify relations in pages.
</para>
<programlisting language="php"><![CDATA[
$container = new Zend_Navigation(array(
array(
'label' => 'Relations using strings',
'rel' => array(
'alternate' => 'http://www.example.org/'
),
'rev' => array(
'alternate' => 'http://www.example.net/'
)
),
array(
'label' => 'Relations using arrays',
'rel' => array(
'alternate' => array(
'label' => 'Example.org',
'uri' => 'http://www.example.org/'
)
)
),
array(
'label' => 'Relations using configs',
'rel' => array(
'alternate' => new Zend_Config(array(
'label' => 'Example.org',
'uri' => 'http://www.example.org/'
))
)
),
array(
'label' => 'Relations using pages instance',
'rel' => array(
'alternate' => Zend_Navigation_Page::factory(array(
'label' => 'Example.org',
'uri' => 'http://www.example.org/'
))
)
)
));
]]></programlisting>
</example>
<example id="zend.view.helpers.initial.navigation.links.example2">
<title>Default rendering of links</title>
<para>
This example shows how to render a menu from a container
registered/found in the view helper.
</para>
<programlisting language="php"><![CDATA[
In a view script or layout:
<?php echo $this->view->navigation()->links(); ?>
Output:
<link rel="alternate" href="/products/server/faq/format/xml">
<link rel="start" href="/" title="Home">
<link rel="next" href="/products/server/editions" title="Editions">
<link rel="prev" href="/products/server" title="Foo Server">
<link rel="chapter" href="/products" title="Products">
<link rel="chapter" href="/company/about" title="Company">
<link rel="chapter" href="/community" title="Community">
<link rel="canonical" href="http://www.example.com/?page=server-faq">
<link rev="subsection" href="/products/server" title="Foo Server">
]]></programlisting>
</example>
<example id="zend.view.helpers.initial.navigation.links.example3">
<title>Specify which relations to render</title>
<para>
This example shows how to specify which relations to find
and render.
</para>
<programlisting language="php"><![CDATA[
Render only start, next, and prev:
$helper->setRenderFlag(Zend_View_Helper_Navigation_Links::RENDER_START |
Zend_View_Helper_Navigation_Links::RENDER_NEXT |
Zend_View_Helper_Navigation_Links::RENDER_PREV);
Output:
<link rel="start" href="/" title="Home">
<link rel="next" href="/products/server/editions" title="Editions">
<link rel="prev" href="/products/server" title="Foo Server">
]]></programlisting>
<programlisting language="php"><![CDATA[
Render only native link types:
$helper->setRenderFlag(Zend_View_Helper_Navigation_Links::RENDER_ALL ^
Zend_View_Helper_Navigation_Links::RENDER_CUSTOM);
Output:
<link rel="alternate" href="/products/server/faq/format/xml">
<link rel="start" href="/" title="Home">
<link rel="next" href="/products/server/editions" title="Editions">
<link rel="prev" href="/products/server" title="Foo Server">
<link rel="chapter" href="/products" title="Products">
<link rel="chapter" href="/company/about" title="Company">
<link rel="chapter" href="/community" title="Community">
<link rev="subsection" href="/products/server" title="Foo Server">
]]></programlisting>
<programlisting language="php"><![CDATA[
Render all but chapter:
$helper->setRenderFlag(Zend_View_Helper_Navigation_Links::RENDER_ALL ^
Zend_View_Helper_Navigation_Links::RENDER_CHAPTER);
Output:
<link rel="alternate" href="/products/server/faq/format/xml">
<link rel="start" href="/" title="Home">
<link rel="next" href="/products/server/editions" title="Editions">
<link rel="prev" href="/products/server" title="Foo Server">
<link rel="canonical" href="http://www.example.com/?page=server-faq">
<link rev="subsection" href="/products/server" title="Foo Server">
]]></programlisting>
</example>
</sect4>
<sect4 id="zend.view.helpers.initial.navigation.menu">
<title>Menu Helper</title>
<para>
The Menu helper is used for rendering menus from navigation
containers. By default, the menu will be rendered using
<acronym>HTML</acronym> <code>UL</code> and <code>LI</code> tags, but the helper also
allows using a partial view script.
</para>
<para>
Methods in the Menu helper:
</para>
<itemizedlist>
<listitem>
<para>
<code>{get|set}UlClass()</code> gets/sets the <acronym>CSS</acronym> class
used in <methodname>renderMenu()</methodname>.
</para>
</listitem>
<listitem>
<para>
<code>{get|set}ActiveClass()</code> gets/sets the <acronym>CSS</acronym> class
for the active elements when rendering.
</para>
</listitem>
<listitem>
<para>
<code>{get|set}OnlyActiveBranch()</code> gets/sets a flag
specifying whether only the active branch of a container
should be rendered.
</para>
</listitem>
<listitem>
<para>
<code>{get|set}ExpandSiblingNodesOfActiveBranch()</code>
gets/sets a flag specifying whether the sibling nodes of all
nodes in the active branch should also be expanded and rendered.
</para>
</listitem>
<listitem>
<para>
<code>{get|set}RenderParents()</code> gets/sets a flag
specifying whether parents should be rendered when only
rendering active branch of a container. If set to
<constant>FALSE</constant>, only the deepest active menu will be
rendered.
</para>
</listitem>
<listitem>
<para>
<code>{get|set}Partial()</code> gets/sets a partial view
script that should be used for rendering menu.
If a partial view script is set, the helper's
<methodname>render()</methodname> method will use the
<methodname>renderPartial()</methodname> method. If no partial is
set, the <methodname>renderMenu()</methodname> method is used.
The helper expects the partial to be a <type>String</type>
or an <type>Array</type> with two elements. If the partial
is a <type>String</type>, it denotes the name of the partial
script to use. If it is an <type>Array</type>, the first
element will be used as the name of the partial view
script, and the second element is the module where the
script is found.
</para>
</listitem>
<listitem>
<para>
<methodname>htmlify()</methodname> overrides the method from the
abstract class to return <code>span</code> elements
if the page has no <code>href</code>.
</para>
</listitem>
<listitem>
<para>
<methodname>renderMenu($container = null, $options = array())</methodname>
is the default render method, and will render a container as
a <acronym>HTML</acronym> <code>UL</code> list.
</para>
<para>
If <varname>$container</varname> is not given, the container
registered in the helper will be rendered.
</para>
<para>
<varname>$options</varname> is used for overriding options
specified temporarily without rsetting the values in the
helper instance. It is an associative array where each key
corresponds to an option in the helper.
</para>
<para>
Recognized options:
</para>
<itemizedlist>
<listitem>
<para>
<code>indent</code>; indentation. Expects a
<type>String</type> or an <code>int</code>
value.
</para>
</listitem>
<listitem>
<para>
<code>minDepth</code>; minimum depth. Expcects
an <code>int</code> or <constant>NULL</constant> (no
minimum depth).
</para>
</listitem>
<listitem>
<para>
<code>maxDepth</code>; maximum depth. Expcects
an <code>int</code> or <constant>NULL</constant> (no
maximum depth).
</para>
</listitem>
<listitem>
<para>
<code>ulClass</code>; <acronym>CSS</acronym> class for
<code>ul</code> element. Expects a
<type>String</type>.
</para>
</listitem>
<listitem>
<para>
<code>activeClass</code>; <acronym>CSS</acronym> class for
for the active elements when rendering. Expects a
<type>String</type>.
</para>
</listitem>
<listitem>
<para>
<code>onlyActiveBranch</code>; whether only
active branch should be rendered. Expects
a <type>Boolean</type> value.
</para>
</listitem>
<listitem>
<para>
<code>expandSiblingNodesOfActiveBranch</code>;
whether the sibling nodes of nodes in the active
branch should be expanded and rendered. Expects
a <type>Boolean</type> value.
</para>
</listitem>
<listitem>
<para>
<code>renderParents</code>; whether parents
should be rendered if only rendering active
branch. Expects a <type>Boolean</type> value.
</para>
</listitem>
</itemizedlist>
<para>
If an option is not given, the value set in the helper
will be used.
</para>
</listitem>
<listitem>
<para>
<methodname>renderPartial()</methodname> is used for rendering the menu
using a partial view script.
</para>
</listitem>
<listitem>
<para>
<methodname>renderSubMenu()</methodname> renders the deepest menu level
of a container's active branch.
</para>
</listitem>
</itemizedlist>
<example id="zend.view.helpers.initial.navigation.menu.example1">
<title>Rendering a menu</title>
<para>
This example shows how to render a menu from a container
registered/found in the view helper. Notice how pages
are filtered out based on visibility and <acronym>ACL</acronym>.
</para>
<programlisting language="php"><![CDATA[
In a view script or layout:
<?php echo $this->navigation()->menu()->render() ?>
Or simply:
<?php echo $this->navigation()->menu() ?>
Output:
<ul class="navigation">
<li>
<a title="Go Home" href="/">Home</a>
</li>
<li class="active">
<a href="/products">Products</a>
<ul>
<li class="active">
<a href="/products/server">Foo Server</a>
<ul>
<li class="active">
<a href="/products/server/faq">FAQ</a>
</li>
<li>
<a href="/products/server/editions">Editions</a>
</li>
<li>
<a href="/products/server/requirements">System Requirements</a>
</li>
</ul>
</li>
<li>
<a href="/products/studio">Foo Studio</a>
<ul>
<li>
<a href="/products/studio/customers">Customer Stories</a>
</li>
<li>
<a href="/prodcts/studio/support">Support</a>
</li>
</ul>
</li>
</ul>
</li>
<li>
<a title="About us" href="/company/about">Company</a>
<ul>
<li>
<a href="/company/about/investors">Investor Relations</a>
</li>
<li>
<a class="rss" href="/company/news">News</a>
<ul>
<li>
<a href="/company/news/press">Press Releases</a>
</li>
<li>
<a href="/archive">Archive</a>
</li>
</ul>
</li>
</ul>
</li>
<li>
<a href="/community">Community</a>
<ul>
<li>
<a href="/community/account">My Account</a>
</li>
<li>
<a class="external" href="http://forums.example.com/">Forums</a>
</li>
</ul>
</li>
</ul>
]]></programlisting>
</example>
<example id="zend.view.helpers.initial.navigation.menu.example2">
<title>Calling renderMenu() directly</title>
<para>
This example shows how to render a menu that is not
registered in the view helper by calling the
<methodname>renderMenu()</methodname> directly and specifying a few
options.
</para>
<programlisting language="php"><![CDATA[
<?php
// render only the 'Community' menu
$community = $this->navigation()->findOneByLabel('Community');
$options = array(
'indent' => 16,
'ulClass' => 'community'
);
echo $this->navigation()
->menu()
->renderMenu($community, $options);
?>
Output:
<ul class="community">
<li>
<a href="/community/account">My Account</a>
</li>
<li>
<a class="external" href="http://forums.example.com/">Forums</a>
</li>
</ul>
]]></programlisting>
</example>
<example id="zend.view.helpers.initial.navigation.menu.example3">
<title>Rendering the deepest active menu</title>
<para>
This example shows how the <methodname>renderSubMenu()</methodname>
will render the deepest sub menu of the active branch.
</para>
<para>
Calling <methodname>renderSubMenu($container, $ulClass, $indent)</methodname>
is equivalent to calling <methodname>renderMenu($container, $options)</methodname>
with the following options:
</para>
<programlisting language="php"><![CDATA[
array(
'ulClass' => $ulClass,
'indent' => $indent,
'minDepth' => null,
'maxDepth' => null,
'onlyActiveBranch' => true,
'renderParents' => false
);
]]></programlisting>
<programlisting language="php"><![CDATA[
<?php
echo $this->navigation()
->menu()
->renderSubMenu(null, 'sidebar', 4);
?>
The output will be the same if 'FAQ' or 'Foo Server' is active:
<ul class="sidebar">
<li class="active">
<a href="/products/server/faq">FAQ</a>
</li>
<li>
<a href="/products/server/editions">Editions</a>
</li>
<li>
<a href="/products/server/requirements">System Requirements</a>
</li>
</ul>
]]></programlisting>
</example>
<example id="zend.view.helpers.initial.navigation.menu.example4">
<title>Rendering a menu with maximum depth</title>
<programlisting language="php"><![CDATA[
<?php
echo $this->navigation()
->menu()
->setMaxDepth(1);
?>
Output:
<ul class="navigation">
<li>
<a title="Go Home" href="/">Home</a>
</li>
<li class="active">
<a href="/products">Products</a>
<ul>
<li class="active">
<a href="/products/server">Foo Server</a>
</li>
<li>
<a href="/products/studio">Foo Studio</a>
</li>
</ul>
</li>
<li>
<a title="About us" href="/company/about">Company</a>
<ul>
<li>
<a href="/company/about/investors">Investor Relations</a>
</li>
<li>
<a class="rss" href="/company/news">News</a>
</li>
</ul>
</li>
<li>
<a href="/community">Community</a>
<ul>
<li>
<a href="/community/account">My Account</a>
</li>
<li>
<a class="external" href="http://forums.example.com/">Forums</a>
</li>
</ul>
</li>
</ul>
]]></programlisting>
</example>
<example id="zend.view.helpers.initial.navigation.menu.example5">
<title>Rendering a menu with minimum depth</title>
<programlisting language="php"><![CDATA[
<?php
echo $this->navigation()
->menu()
->setMinDepth(1);
?>
Output:
<ul class="navigation">
<li class="active">
<a href="/products/server">Foo Server</a>
<ul>
<li class="active">
<a href="/products/server/faq">FAQ</a>
</li>
<li>
<a href="/products/server/editions">Editions</a>
</li>
<li>
<a href="/products/server/requirements">System Requirements</a>
</li>
</ul>
</li>
<li>
<a href="/products/studio">Foo Studio</a>
<ul>
<li>
<a href="/products/studio/customers">Customer Stories</a>
</li>
<li>
<a href="/prodcts/studio/support">Support</a>
</li>
</ul>
</li>
<li>
<a href="/company/about/investors">Investor Relations</a>
</li>
<li>
<a class="rss" href="/company/news">News</a>
<ul>
<li>
<a href="/company/news/press">Press Releases</a>
</li>
<li>
<a href="/archive">Archive</a>
</li>
</ul>
</li>
<li>
<a href="/community/account">My Account</a>
</li>
<li>
<a class="external" href="http://forums.example.com/">Forums</a>
</li>
</ul>
]]></programlisting>
</example>
<example id="zend.view.helpers.initial.navigation.menu.example6">
<title>Rendering only the active branch of a menu</title>
<programlisting language="php"><![CDATA[
<?php
echo $this->navigation()
->menu()
->setOnlyActiveBranch(true);
?>
Output:
<ul class="navigation">
<li class="active">
<a href="/products">Products</a>
<ul>
<li class="active">
<a href="/products/server">Foo Server</a>
<ul>
<li class="active">
<a href="/products/server/faq">FAQ</a>
</li>
<li>
<a href="/products/server/editions">Editions</a>
</li>
<li>
<a href="/products/server/requirements">System Requirements</a>
</li>
</ul>
</li>
</ul>
</li>
</ul>
]]></programlisting>
</example>
<example id="zend.view.helpers.initial.navigation.menu.example7">
<title>
Rendering only the active branch of a menu with minimum depth
</title>
<programlisting language="php"><![CDATA[
<?php
echo $this->navigation()
->menu()
->setOnlyActiveBranch(true)
->setMinDepth(1);
?>
Output:
<ul class="navigation">
<li class="active">
<a href="/products/server">Foo Server</a>
<ul>
<li class="active">
<a href="/products/server/faq">FAQ</a>
</li>
<li>
<a href="/products/server/editions">Editions</a>
</li>
<li>
<a href="/products/server/requirements">System Requirements</a>
</li>
</ul>
</li>
</ul>
]]></programlisting>
</example>
<example id="zend.view.helpers.initial.navigation.menu.example8">
<title>
Rendering only the active branch of a menu with maximum depth
</title>
<programlisting language="php"><![CDATA[
<?php
echo $this->navigation()
->menu()
->setOnlyActiveBranch(true)
->setMaxDepth(1);
?>
Output:
<ul class="navigation">
<li class="active">
<a href="/products">Products</a>
<ul>
<li class="active">
<a href="/products/server">Foo Server</a>
</li>
<li>
<a href="/products/studio">Foo Studio</a>
</li>
</ul>
</li>
</ul>
]]></programlisting>
</example>
<example id="zend.view.helpers.initial.navigation.menu.example9">
<title>
Rendering only the active branch of a menu with maximum depth
and no parents
</title>
<para>
</para>
<programlisting language="php"><![CDATA[
<?php
echo $this->navigation()
->menu()
->setOnlyActiveBranch(true)
->setRenderParents(false)
->setMaxDepth(1);
?>
Output:
<ul class="navigation">
<li class="active">
<a href="/products/server">Foo Server</a>
</li>
<li>
<a href="/products/studio">Foo Studio</a>
</li>
</ul>
]]></programlisting>
</example>
<example id="zend.view.helpers.initial.navigation.menu.example10">
<title>Rendering a custom menu using a partial view script</title>
<para>
This example shows how to render a custom menu using
a partial vew script. By calling <methodname>setPartial()</methodname>,
you can specify a partial view script that will be used
when calling <methodname>render()</methodname>. When a partial is specified,
the <methodname>renderPartial()</methodname> method will be called. This
method will assign the container to the view with the key
<code>container</code>.
</para>
<para>In a layout:</para>
<programlisting language="php"><![CDATA[
$partial = array('menu.phtml', 'default');
$this->navigation()->menu()->setPartial($partial);
echo $this->navigation()->menu()->render();
]]></programlisting>
<para>In application/modules/default/views/menu.phtml:</para>
<programlisting language="php"><![CDATA[
foreach ($this->container as $page) {
echo $this->navigation()->menu()->htmlify($page), PHP_EOL;
}
]]></programlisting>
<para>Output:</para>
<programlisting language="php"><![CDATA[
<a title="Go Home" href="/">Home</a>
<a href="/products">Products</a>
<a title="About us" href="/company/about">Company</a>
<a href="/community">Community</a>
]]></programlisting>
</example>
<example id="zend.view.helpers.initial.navigation.menu.example11">
<title>
Rendering only the active branch and all siblings of the active branch
</title>
<programlisting language="php"><![CDATA[
echo $this->navigation()
->menu()
->setExpandSiblingNodesOfActiveBranch(true);
]]></programlisting>
<para>Output:</para>
<programlisting language="php"><![CDATA[
<ul class="navigation">
<li>
<a title="Go Home" href="/">Home</a>
</li>
<li class="active">
<a href="/products">Products</a>
<ul>
<li class="active">
<a href="/products/server">Foo Server</a>
<ul>
<li class="active">
<a href="/products/server/faq">FAQ</a>
</li>
<li>
<a href="/products/server/editions">Editions</a>
</li>
<li>
<a href="/products/server/requirements">System Requirements</a>
</li>
</ul>
</li>
<li>
<a href="/products/studio">Foo Studio</a>
</li>
</ul>
</li>
<li>
<a title="About us" href="/company/about">Company</a>
</li>
<li>
<a href="/community">Community</a>
</li>
</ul>
]]></programlisting>
</example>
</sect4>
<sect4 id="zend.view.helpers.initial.navigation.sitemap">
<title>Sitemap Helper</title>
<para>
The Sitemap helper is used for generating <acronym>XML</acronym> sitemaps, as
defined by the <ulink
url="http://www.sitemaps.org/protocol.php">Sitemaps <acronym>XML</acronym>
format</ulink>. Read more about <ulink
url="http://en.wikipedia.org/wiki/Sitemaps">Sitemaps on Wikpedia</ulink>.
</para>
<para>
By default, the sitemap helper uses
<link linkend="zend.validate.sitemap">sitemap validators</link>
to validate each element that is rendered. This can be disabled by
calling <code>$helper->setUseSitemapValidators(false)</code>.
</para>
<note>
<para>
If you disable sitemap validators, the custom properties (see table)
are not validated at all.
</para>
</note>
<para>
The sitemap helper also supports <ulink
url="http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd">Sitemap XSD
Schema</ulink> validation of the generated sitemap. This is disabled by default,
since it will require a request to the Schema file. It can be
enabled with
<code>$helper->setUseSchemaValidation(true)</code>.
</para>
<table id="zend.view.helpers.initial.navigation.sitemap.elements">
<title>Sitemap XML elements</title>
<tgroup cols="2">
<thead>
<row>
<entry>Element</entry>
<entry>Description</entry>
</row>
</thead>
<tbody>
<row>
<entry><code>loc</code></entry>
<entry>
Absolute <acronym>URL</acronym> to page. An absolute
<acronym>URL</acronym> will be generated by the helper.
</entry>
</row>
<row>
<entry><code>lastmod</code></entry>
<entry>
<para>
The date of last modification of the file, in <ulink
url="http://www.w3.org/TR/NOTE-datetime">W3C Datetime</ulink>
format. This time portion can be omitted if desired, and only use
YYYY-MM-DD.
</para>
<para>
The helper will try to retrieve the
<code>lastmod</code> value from the page's
custom property <code>lastmod</code> if it
is set in the page. If the value is not a
valid date, it is ignored.
</para>
</entry>
</row>
<row>
<entry><code>changefreq</code></entry>
<entry>
<para>
How frequently the page is likely to change.
This value provides general information to
search engines and may not correlate exactly
to how often they crawl the page. Valid
values are:
</para>
<itemizedlist>
<listitem><para>always</para></listitem>
<listitem><para>hourly</para></listitem>
<listitem><para>daily</para></listitem>
<listitem><para>weekly</para></listitem>
<listitem><para>monthly</para></listitem>
<listitem><para>yearly</para></listitem>
<listitem><para>never</para></listitem>
</itemizedlist>
<para>
The helper will try to retrieve the
<code>changefreq</code> value from the page's
custom property <code>changefreq</code> if it
is set in the page. If the value is not
valid, it is ignored.
</para>
</entry>
</row>
<row>
<entry><code>priority</code></entry>
<entry>
<para>
The priority of this <acronym>URL</acronym> relative to other
<acronym>URL</acronym>s on your site. Valid values range from
0.0 to 1.0.
</para>
<para>
The helper will try to retrieve the
<code>priority</code> value from the page's
custom property <code>priority</code> if it
is set in the page. If the value is not
valid, it is ignored.
</para>
</entry>
</row>
</tbody>
</tgroup>
</table>
<para>
Methods in the sitemap helper:
</para>
<itemizedlist>
<listitem>
<para>
<code>{get|set}FormatOutput()</code> gets/sets a flag
indicating whether <acronym>XML</acronym> output should be formatted. This
corresponds to the <code>formatOutput</code> property
of the native <classname>DOMDocument</classname> class.
Read more at
<ulink url="http://php.net/domdocument">PHP: DOMDocument - Manual</ulink>.
Default is <constant>FALSE</constant>.
</para>
</listitem>
<listitem>
<para>
<code>{get|set}UseXmlDeclaration()</code> gets/sets a
flag indicating whether the <acronym>XML</acronym> declaration should be
included when rendering. Default is <constant>TRUE</constant>.
</para>
</listitem>
<listitem>
<para>
<code>{get|set}UseSitemapValidators()</code> gets/sets a
flag indicating whether sitemap validators should be
used when generating the DOM sitemap. Default is
<constant>TRUE</constant>.
</para>
</listitem>
<listitem>
<para>
<code>{get|set}UseSchemaValidation()</code> gets/sets a
flag indicating whether the helper should use <acronym>XML</acronym> Schema
validation when generating the DOM sitemap. Default is
<constant>FALSE</constant>. If <constant>TRUE</constant>.
</para>
</listitem>
<listitem>
<para>
<code>{get|set}ServerUrl()</code> gets/sets server <acronym>URL</acronym>
that will be prepended to non-absolute <acronym>URL</acronym>s in the
<methodname>url()</methodname> method. If no server <acronym>URL</acronym> is
specified, it will be determined by the helper.
</para>
</listitem>
<listitem>
<para>
<methodname>url()</methodname> is used to generate absolute
<acronym>URL</acronym>s to pages.
</para>
</listitem>
<listitem>
<para>
<methodname>getDomSitemap()</methodname> generates a DOMDocument
from a given container.
</para>
</listitem>
</itemizedlist>
<example id="zend.view.helpers.initial.navigation.sitemap.example">
<title>Rendering an XML sitemap</title>
<para>
This example shows how to render an <acronym>XML</acronym> sitemap based
on the setup we did further up.
</para>
<programlisting language="php"><![CDATA[
// In a view script or layout:
// format output
$this->navigation()
->sitemap()
->setFormatOutput(true); // default is false
// other possible methods:
// ->setUseXmlDeclaration(false); // default is true
// ->setServerUrl('http://my.otherhost.com');
// default is to detect automatically
// print sitemap
echo $this->navigation()->sitemap();
]]></programlisting>
<para>
Notice how pages that are invisible or pages with
<acronym>ACL</acronym> roles incompatible with the view helper are filtered
out:
</para>
<programlisting language="xml"><![CDATA[
<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<url>
<loc>http://www.example.com/</loc>
</url>
<url>
<loc>http://www.example.com/products</loc>
</url>
<url>
<loc>http://www.example.com/products/server</loc>
</url>
<url>
<loc>http://www.example.com/products/server/faq</loc>
</url>
<url>
<loc>http://www.example.com/products/server/editions</loc>
</url>
<url>
<loc>http://www.example.com/products/server/requirements</loc>
</url>
<url>
<loc>http://www.example.com/products/studio</loc>
</url>
<url>
<loc>http://www.example.com/products/studio/customers</loc>
</url>
<url>
<loc>http://www.example.com/prodcts/studio/support</loc>
</url>
<url>
<loc>http://www.example.com/company/about</loc>
</url>
<url>
<loc>http://www.example.com/company/about/investors</loc>
</url>
<url>
<loc>http://www.example.com/company/news</loc>
</url>
<url>
<loc>http://www.example.com/company/news/press</loc>
</url>
<url>
<loc>http://www.example.com/archive</loc>
</url>
<url>
<loc>http://www.example.com/community</loc>
</url>
<url>
<loc>http://www.example.com/community/account</loc>
</url>
<url>
<loc>http://forums.example.com/</loc>
</url>
</urlset>
]]></programlisting>
<para>
Render the sitemap using no <acronym>ACL</acronym> role (should filter out
/community/account):
</para>
<programlisting language="php"><![CDATA[
echo $this->navigation()
->sitemap()
->setFormatOutput(true)
->setRole();
]]></programlisting>
<programlisting language="xml"><![CDATA[
<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<url>
<loc>http://www.example.com/</loc>
</url>
<url>
<loc>http://www.example.com/products</loc>
</url>
<url>
<loc>http://www.example.com/products/server</loc>
</url>
<url>
<loc>http://www.example.com/products/server/faq</loc>
</url>
<url>
<loc>http://www.example.com/products/server/editions</loc>
</url>
<url>
<loc>http://www.example.com/products/server/requirements</loc>
</url>
<url>
<loc>http://www.example.com/products/studio</loc>
</url>
<url>
<loc>http://www.example.com/products/studio/customers</loc>
</url>
<url>
<loc>http://www.example.com/prodcts/studio/support</loc>
</url>
<url>
<loc>http://www.example.com/company/about</loc>
</url>
<url>
<loc>http://www.example.com/company/about/investors</loc>
</url>
<url>
<loc>http://www.example.com/company/news</loc>
</url>
<url>
<loc>http://www.example.com/company/news/press</loc>
</url>
<url>
<loc>http://www.example.com/archive</loc>
</url>
<url>
<loc>http://www.example.com/community</loc>
</url>
<url>
<loc>http://forums.example.com/</loc>
</url>
</urlset>
]]></programlisting>
<para>
Render the sitemap using a maximum depth of 1.
</para>
<programlisting language="php"><![CDATA[
echo $this->navigation()
->sitemap()
->setFormatOutput(true)
->setMaxDepth(1);
]]></programlisting>
<programlisting language="xml"><![CDATA[
<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<url>
<loc>http://www.example.com/</loc>
</url>
<url>
<loc>http://www.example.com/products</loc>
</url>
<url>
<loc>http://www.example.com/products/server</loc>
</url>
<url>
<loc>http://www.example.com/products/studio</loc>
</url>
<url>
<loc>http://www.example.com/company/about</loc>
</url>
<url>
<loc>http://www.example.com/company/about/investors</loc>
</url>
<url>
<loc>http://www.example.com/company/news</loc>
</url>
<url>
<loc>http://www.example.com/community</loc>
</url>
<url>
<loc>http://www.example.com/community/account</loc>
</url>
<url>
<loc>http://forums.example.com/</loc>
</url>
</urlset>
]]></programlisting>
</example>
<note>
<title>UTF-8 encoding used by default</title>
<para>
By default, Zend Framework uses <acronym>UTF-8</acronym> as its default encoding,
and, specific to this case, <classname>Zend_View</classname> does as well. Character
encoding can be set differently on the view object itself using the
<methodname>setEncoding()</methodname> method (or the
<varname>encoding</varname> instantiation parameter). However, since
<classname>Zend_View_Interface</classname> does not define accessors for encoding,
it's possible that if you are using a custom view implementation with the Dojo view
helper, you will not have a <methodname>getEncoding()</methodname> method, which is
what the view helper uses internally for determining the character set in which to
encode.
</para>
<para>
If you do not want to utilize <acronym>UTF-8</acronym> in such a situation, you will
need to implement a <methodname>getEncoding()</methodname> method in your custom
view implementation.
</para>
</note>
</sect4>
<sect4 id="zend.view.helpers.initial.navigation.navigation">
<title>Navigation Helper</title>
<para>
The Navigation helper is a proxy helper
that relays calls to other navigational helpers. It can be
considered an entry point to all navigation-related view tasks.
The aforementioned navigational helpers are in the namespace
<classname>Zend_View_Helper_Navigation</classname>, and would thus require
the path <code>Zend/View/Helper/Navigation</code> to be added as
a helper path to the view. With the proxy helper residing in the
<classname>Zend_View_Helper</classname> namespace, it will always be
available, without the need to add any helper paths to the view.
</para>
<para>
The Navigation helper finds other helpers that implement the
<classname>Zend_View_Helper_Navigation_Helper</classname>
interface, which means custom view helpers can also be proxied.
This would, however, require that the custom helper path is added
to the view.
</para>
<para>
When proxying to other helpers, the Navigation helper can inject
its container, <acronym>ACL</acronym>/role, and translator. This means that you
won't have to explicitly set all three in all navigational
helpers, nor resort to injecting by means of
<classname>Zend_Registry</classname> or static methods.
</para>
<itemizedlist>
<listitem>
<para>
<methodname>findHelper()</methodname> finds the given helper,
verifies that it is a navigational helper, and injects
container, <acronym>ACL</acronym>/role and translator.
</para>
</listitem>
<listitem>
<para>
<code>{get|set}InjectContainer()</code> gets/sets a flag
indicating whether the container should be injected to
proxied helpers. Default is <constant>TRUE</constant>.
</para>
</listitem>
<listitem>
<para>
<code>{get|set}InjectAcl()</code> gets/sets a flag
indicating whether the <acronym>ACL</acronym>/role should be injected to
proxied helpers. Default is <constant>TRUE</constant>.
</para>
</listitem>
<listitem>
<para>
<code>{get|set}InjectTranslator()</code> gets/sets a flag
indicating whether the translator should be injected to
proxied helpers. Default is <constant>TRUE</constant>.
</para>
</listitem>
<listitem>
<para>
<code>{get|set}DefaultProxy()</code> gets/sets the default
proxy. Default is <code>'menu'</code>.
</para>
</listitem>
<listitem>
<para>
<methodname>render()</methodname> proxies to the render method of
the default proxy.
</para>
</listitem>
</itemizedlist>
</sect4>
</sect3>
|