2
0

Zend_View-Helpers-Navigation.xml 81 KB

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