Zend_View-Helpers-Navigation.xml 79 KB

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