Zend_Navigation-Pages-Common.xml 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!-- Reviewed: no -->
  3. <sect2 id="zend.navigation.pages.common">
  4. <title>Common page features</title>
  5. <para>
  6. All page classes must extend <classname>Zend_Navigation_Page</classname>,
  7. and will thus share a common set of features and properties. Most notably
  8. they share the options in the table below and the same initialization
  9. process.
  10. </para>
  11. <para>
  12. Option keys are mapped to <code>set</code> methods. This means that
  13. the option <code>order</code> maps to the method <code>setOrder()</code>,
  14. and <code>reset_params</code> maps to the method
  15. <code>setResetParams()</code>. If there is no setter method for
  16. the option, it will be set as a custom property of the page.
  17. </para>
  18. <para>
  19. Read more on extending Zend_Navigation_Page in
  20. <link linkend="zend.navigation.pages.custom">Creating custom page types</link>.
  21. </para>
  22. <table id="zend.navigation.pages.common.options">
  23. <title>Common page options</title>
  24. <tgroup cols="4">
  25. <thead>
  26. <row>
  27. <entry>Key</entry>
  28. <entry>Type</entry>
  29. <entry>Default</entry>
  30. <entry>Description</entry>
  31. </row>
  32. </thead>
  33. <tbody>
  34. <row>
  35. <entry><code>label</code></entry>
  36. <entry><type>String</type></entry>
  37. <entry><constant>NULL</constant></entry>
  38. <entry>
  39. A page label, such as 'Home' or 'Blog'.
  40. </entry>
  41. </row>
  42. <row>
  43. <entry><code>id</code></entry>
  44. <entry><type>String</type> | <code>int</code></entry>
  45. <entry><constant>NULL</constant></entry>
  46. <entry>
  47. An id tag/attribute that may be used when rendering
  48. the page, typically in an anchor element.
  49. </entry>
  50. </row>
  51. <row>
  52. <entry><code>class</code></entry>
  53. <entry><type>String</type></entry>
  54. <entry><constant>NULL</constant></entry>
  55. <entry>
  56. A CSS class that may be used when rendering the page,
  57. typically in an anchor element.
  58. </entry>
  59. </row>
  60. <row>
  61. <entry><code>title</code></entry>
  62. <entry><type>String</type></entry>
  63. <entry><constant>NULL</constant></entry>
  64. <entry>
  65. A short page description, typically for using
  66. as the <code>title</code> attribute in an anchor.
  67. </entry>
  68. </row>
  69. <row>
  70. <entry><code>target</code></entry>
  71. <entry><type>String</type></entry>
  72. <entry><constant>NULL</constant></entry>
  73. <entry>
  74. Specifies a target that may be used for the page,
  75. typically in an anchor element.
  76. </entry>
  77. </row>
  78. <row>
  79. <entry><code>rel</code></entry>
  80. <entry><type>Array</type></entry>
  81. <entry><code>array()</code></entry>
  82. <entry>
  83. Specifies forward relations for the page.
  84. Each element in the array is a key-value pair, where the
  85. key designates the relation/link type, and the value is
  86. a pointer to the linked page. An example of a key-value
  87. pair is <code>'alternate' => 'format/plain.html'</code>.
  88. To allow full flexbility, there are no restrictions on
  89. relation values. The value does not have to be a string.
  90. Read more about <code>rel</code> and <code>rev</code> in
  91. <link linkend="zend.view.helpers.initial.navigation.links">the
  92. section on the Links helper.</link>.
  93. </entry>
  94. </row>
  95. <row>
  96. <entry><code>rev</code></entry>
  97. <entry><type>Array</type></entry>
  98. <entry><code>array()</code></entry>
  99. <entry>
  100. Specifies reverse relations for the page. Works exactly
  101. like <code>rel</code>.
  102. </entry>
  103. </row>
  104. <row>
  105. <entry><code>order</code></entry>
  106. <entry><type>String</type> | <code>int</code> | <constant>NULL</constant></entry>
  107. <entry><constant>NULL</constant></entry>
  108. <entry>
  109. Works like order for elements in
  110. <link linkend="zend.form.quickstart.render">
  111. <classname>Zend_Form</classname></link>. If specified,
  112. the page will be iterated in a specific order, meaning
  113. you can force a page to be iterated before others by
  114. setting the <code>order</code> attribute to a low number,
  115. e.g. -100. If a <type>String</type> is given, it must
  116. parse to a valid <code>int</code>. If <constant>NULL</constant>
  117. is given, it will be reset, meaning the order in which
  118. the page was added to the container will be used.
  119. </entry>
  120. </row>
  121. <row>
  122. <entry><code>resource</code></entry>
  123. <entry><type>String</type> | <classname>Zend_Acl_Resource_Interface</classname> | <constant>NULL</constant></entry>
  124. <entry><constant>NULL</constant></entry>
  125. <entry>
  126. ACL resource to associate with the page. Read more in
  127. <link linkend="zend.view.helpers.initial.navigation.acl">the
  128. section on ACL integration in view helpers.</link>.
  129. </entry>
  130. </row>
  131. <row>
  132. <entry><code>privilege</code></entry>
  133. <entry><type>String</type> | <constant>NULL</constant></entry>
  134. <entry><constant>NULL</constant></entry>
  135. <entry>
  136. ACL privilege to associate with the page. Read more in
  137. <link linkend="zend.view.helpers.initial.navigation.acl">the
  138. section on ACL integration in view helpers.</link>.
  139. </entry>
  140. </row>
  141. <row>
  142. <entry><code>active</code></entry>
  143. <entry><code>bool</code></entry>
  144. <entry><constant>FALSE</constant></entry>
  145. <entry>
  146. Whether the page should be considered active for the
  147. current request. If active is <constant>FALSE</constant> or not
  148. given, MVC pages will check its properties against the
  149. request object upon calling <code>$page->isActive()</code>.
  150. </entry>
  151. </row>
  152. <row>
  153. <entry><code>visible</code></entry>
  154. <entry><code>bool</code></entry>
  155. <entry><constant>TRUE</constant></entry>
  156. <entry>
  157. Whether page should be visible for the user, or just
  158. be a part of the structure. Invisible pages are skipped
  159. by view helpers.
  160. </entry>
  161. </row>
  162. <row>
  163. <entry><code>pages</code></entry>
  164. <entry><type>Array</type> | <classname>Zend_Config</classname> | <constant>NULL</constant></entry>
  165. <entry><constant>NULL</constant></entry>
  166. <entry>
  167. Child pages of the page. This could be an <type>Array</type>
  168. or <classname>Zend_Config</classname> object containing either page
  169. options that can be passed to the <code>factory()</code>
  170. method, or actual <classname>Zend_Navigation_Page</classname>
  171. instances, or a mixture of both.
  172. </entry>
  173. </row>
  174. </tbody>
  175. </tgroup>
  176. </table>
  177. <note>
  178. <title>Custom properties</title>
  179. <para>
  180. All pages support setting and getting of custom properties by
  181. use of the magic methods <code>__set($name, $value)</code>,
  182. <code>__get($name)</code>, <code>__isset($name)</code> and
  183. <code>__unset($name)</code>. Custom properties may have any value,
  184. and will be included in the array that is returned from
  185. <code>$page->toArray()</code>, which means that pages
  186. can be serialized/deserialized successfully even if the pages
  187. contains properties that are not native in the page class.
  188. </para>
  189. <para>
  190. Both native and custom properties can be set using
  191. <code>$page->set($name, $value)</code> and retrieved using
  192. <code>$page->get($name)</code>, or by using magic methods.
  193. </para>
  194. </note>
  195. <example id="zend.navigation.pages.common.example.customprops">
  196. <title>Custom page properties</title>
  197. <para>
  198. This example shows how custom properties can be used.
  199. </para>
  200. <programlisting language="php"><![CDATA[
  201. $page = new Zend_Navigation_Page_Mvc();
  202. $page->foo = 'bar';
  203. $page->meaning = 42;
  204. echo $page->foo;
  205. if ($page->meaning != 42) {
  206. // action should be taken
  207. }
  208. ]]></programlisting>
  209. </example>
  210. </sect2>