/doc/core/m_category.html

https://code.google.com/p/zotonic/ · HTML · 252 lines · 211 code · 41 blank · 0 comment · 0 complexity · 6bf4d94716eb908f9b84a6f6fbc3c07a MD5 · raw file

  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
  2. <html>
  3. <head>
  4. <title>Module m_category</title>
  5. <link rel="stylesheet" type="text/css" href="stylesheet.css" title="EDoc">
  6. </head>
  7. <body bgcolor="white">
  8. <div class="navbar"><a name="#navbar_top"></a><table width="100%" border="0" cellspacing="0" cellpadding="2" summary="navigation bar"><tr><td><a href="overview-summary.html" target="overviewFrame">Overview</a></td><td><a href="http://www.erlang.org/"><img src="erlang.png" align="right" border="0" alt="erlang logo"></a></td></tr></table></div>
  9. <hr>
  10. <h1>Module m_category</h1>
  11. <ul class="index"><li><a href="#description">Description</a></li><li><a href="#index">Function Index</a></li><li><a href="#functions">Function Details</a></li></ul>Model for categories.
  12. <p>Copyright Š 2009 Marc Worrell
  13. Date: 2009-04-08
  14. </p>
  15. <p><b>Behaviours:</b> <a href="gen_model.html"><tt>gen_model</tt></a>.</p>
  16. <p><b>Authors:</b> Marc Worrell (<a href="mailto:marc@worrell.nl"><tt>marc@worrell.nl</tt></a>).</p>
  17. <h2><a name="description">Description</a></h2>Model for categories. Add, change and re-order categories.
  18. <h2><a name="index">Function Index</a></h2>
  19. <table width="100%" border="1" cellspacing="0" cellpadding="2" summary="function index"><tr><td valign="top"><a href="#all_flat-1">all_flat/1</a></td><td>Return a flattened representation of the complete category tree.</td></tr>
  20. <tr><td valign="top"><a href="#all_flat-2">all_flat/2</a></td><td></td></tr>
  21. <tr><td valign="top"><a href="#all_flat_meta-1">all_flat_meta/1</a></td><td></td></tr>
  22. <tr><td valign="top"><a href="#boundaries-2">boundaries/2</a></td><td></td></tr>
  23. <tr><td valign="top"><a href="#delete-3">delete/3</a></td><td>Delete the category, move referring pages to another category.</td></tr>
  24. <tr><td valign="top"><a href="#enumerate-1">enumerate/1</a></td><td>Take a category list and make it into a tree, recalculating the left/right and lvl nrs.</td></tr>
  25. <tr><td valign="top"><a href="#get-2">get/2</a></td><td></td></tr>
  26. <tr><td valign="top"><a href="#get_by_name-2">get_by_name/2</a></td><td></td></tr>
  27. <tr><td valign="top"><a href="#get_by_parent-2">get_by_parent/2</a></td><td></td></tr>
  28. <tr><td valign="top"><a href="#get_page_count-2">get_page_count/2</a></td><td></td></tr>
  29. <tr><td valign="top"><a href="#get_path-2">get_path/2</a></td><td>Return the path from a root to the category (excluding the category itself).</td></tr>
  30. <tr><td valign="top"><a href="#get_range-2">get_range/2</a></td><td></td></tr>
  31. <tr><td valign="top"><a href="#get_range_by_name-2">get_range_by_name/2</a></td><td></td></tr>
  32. <tr><td valign="top"><a href="#get_root-1">get_root/1</a></td><td></td></tr>
  33. <tr><td valign="top"><a href="#id_to_name-2">id_to_name/2</a></td><td></td></tr>
  34. <tr><td valign="top"><a href="#image-2">image/2</a></td><td></td></tr>
  35. <tr><td valign="top"><a href="#insert-4">insert/4</a></td><td></td></tr>
  36. <tr><td valign="top"><a href="#is_a-2">is_a/2</a></td><td>Return the list of categories (as atoms) that the category is part of.</td></tr>
  37. <tr><td valign="top"><a href="#is_a-3">is_a/3</a></td><td>Check if the id is within another category.</td></tr>
  38. <tr><td valign="top"><a href="#last_modified-2">last_modified/2</a></td><td>Return the last modification date of the category.</td></tr>
  39. <tr><td valign="top"><a href="#m_find_value-3">m_find_value/3</a></td><td>Fetch the value for the key from a model source.</td></tr>
  40. <tr><td valign="top"><a href="#m_to_list-2">m_to_list/2</a></td><td>Transform a m_config value to a list, used for template loops.</td></tr>
  41. <tr><td valign="top"><a href="#m_value-2">m_value/2</a></td><td>Transform a model value so that it can be formatted or piped through filters.</td></tr>
  42. <tr><td valign="top"><a href="#move_before-3">move_before/3</a></td><td>Move a category in front of another category, resetting the parent of the moved category to
  43. the parent of the other category.</td></tr>
  44. <tr><td valign="top"><a href="#move_below-3">move_below/3</a></td><td>Move the category below another category, placing it at the end of the children of that category.</td></tr>
  45. <tr><td valign="top"><a href="#move_end-2">move_end/2</a></td><td>Move the category to the end of all categories, making it a top category in the process.</td></tr>
  46. <tr><td valign="top"><a href="#name_to_id-2">name_to_id/2</a></td><td></td></tr>
  47. <tr><td valign="top"><a href="#name_to_id_check-2">name_to_id_check/2</a></td><td></td></tr>
  48. <tr><td valign="top"><a href="#ranges-2">ranges/2</a></td><td>Given a list of category ids, return the list of numeric ranges they cover.</td></tr>
  49. <tr><td valign="top"><a href="#renumber-1">renumber/1</a></td><td>Renumber all categories so that the left/right and level indices are correct.</td></tr>
  50. <tr><td valign="top"><a href="#renumber_pivot_task-2">renumber_pivot_task/2</a></td><td>Resync all ids that have their category nr changed.</td></tr>
  51. <tr><td valign="top"><a href="#tree-1">tree/1</a></td><td>Return the tree of all categories.</td></tr>
  52. <tr><td valign="top"><a href="#tree-2">tree/2</a></td><td>Return the tree of all categories below a category id.</td></tr>
  53. <tr><td valign="top"><a href="#tree_depth-2">tree_depth/2</a></td><td>Return the tree of all categories till a certain depth.</td></tr>
  54. <tr><td valign="top"><a href="#tree_depth-3">tree_depth/3</a></td><td>Return the tree of all categories below a category id till a certain depth.</td></tr>
  55. <tr><td valign="top"><a href="#update_sequence-2">update_sequence/2</a></td><td></td></tr>
  56. </table>
  57. <h2><a name="functions">Function Details</a></h2>
  58. <h3 class="function"><a name="all_flat-1">all_flat/1</a></h3>
  59. <div class="spec">
  60. <p><tt>all_flat(Context) -&gt; any()</tt></p>
  61. </div><p>Return a flattened representation of the complete category tree. Can be used for overviews or select boxes.
  62. The "meta" categories of predicate, category and group are suppressed.</p>
  63. <h3 class="function"><a name="all_flat-2">all_flat/2</a></h3>
  64. <div class="spec">
  65. <p><tt>all_flat(CatId, Context) -&gt; any()</tt></p>
  66. </div>
  67. <h3 class="function"><a name="all_flat_meta-1">all_flat_meta/1</a></h3>
  68. <div class="spec">
  69. <p><tt>all_flat_meta(Context) -&gt; any()</tt></p>
  70. </div>
  71. <h3 class="function"><a name="boundaries-2">boundaries/2</a></h3>
  72. <div class="spec">
  73. <p><tt>boundaries(CatId::Id, Context::C) -&gt; {Left, Right}</tt></p>
  74. </div>
  75. <h3 class="function"><a name="delete-3">delete/3</a></h3>
  76. <div class="spec">
  77. <p><tt>delete(Id::<a href="#type-int">int()</a>, TransferId::<a href="#type-int">int()</a>, Context) -&gt; ok | {error, Reason}</tt></p>
  78. </div><p>Delete the category, move referring pages to another category. Fails when the transfer id is not a category.</p>
  79. <h3 class="function"><a name="enumerate-1">enumerate/1</a></h3>
  80. <div class="spec">
  81. <p><tt>enumerate(Cats::[Cat]) -&gt; [Sort]</tt>
  82. <ul class="definitions"><li><tt>Cat = {CatId, Parent, NodeSeq}</tt></li>
  83. <li><tt>Sort = {CatId, Nr, Level, Left, Right, Path}</tt></li>
  84. </ul></p>
  85. </div><p>Take a category list and make it into a tree, recalculating the left/right and lvl nrs</p>
  86. <h3 class="function"><a name="get-2">get/2</a></h3>
  87. <div class="spec">
  88. <p><tt>get(Name, Context) -&gt; any()</tt></p>
  89. </div>
  90. <h3 class="function"><a name="get_by_name-2">get_by_name/2</a></h3>
  91. <div class="spec">
  92. <p><tt>get_by_name(Name, Context) -&gt; any()</tt></p>
  93. </div>
  94. <h3 class="function"><a name="get_by_parent-2">get_by_parent/2</a></h3>
  95. <div class="spec">
  96. <p><tt>get_by_parent(Id, Context) -&gt; any()</tt></p>
  97. </div>
  98. <h3 class="function"><a name="get_page_count-2">get_page_count/2</a></h3>
  99. <div class="spec">
  100. <p><tt>get_page_count(Id, Context) -&gt; any()</tt></p>
  101. </div>
  102. <h3 class="function"><a name="get_path-2">get_path/2</a></h3>
  103. <div class="spec">
  104. <p><tt>get_path(Id, Context) -&gt; [CatId]</tt></p>
  105. </div><p>Return the path from a root to the category (excluding the category itself)</p>
  106. <h3 class="function"><a name="get_range-2">get_range/2</a></h3>
  107. <div class="spec">
  108. <p><tt>get_range(Id, Context) -&gt; any()</tt></p>
  109. </div>
  110. <h3 class="function"><a name="get_range_by_name-2">get_range_by_name/2</a></h3>
  111. <div class="spec">
  112. <p><tt>get_range_by_name(Name, Context) -&gt; any()</tt></p>
  113. </div>
  114. <h3 class="function"><a name="get_root-1">get_root/1</a></h3>
  115. <div class="spec">
  116. <p><tt>get_root(Context) -&gt; any()</tt></p>
  117. </div>
  118. <h3 class="function"><a name="id_to_name-2">id_to_name/2</a></h3>
  119. <div class="spec">
  120. <p><tt>id_to_name(Name, Context) -&gt; any()</tt></p>
  121. </div>
  122. <h3 class="function"><a name="image-2">image/2</a></h3>
  123. <div class="spec">
  124. <p><tt>image(Id, Context) -&gt; any()</tt></p>
  125. </div>
  126. <h3 class="function"><a name="insert-4">insert/4</a></h3>
  127. <div class="spec">
  128. <p><tt>insert(ParentId, Name, Props, Context) -&gt; any()</tt></p>
  129. </div>
  130. <h3 class="function"><a name="is_a-2">is_a/2</a></h3>
  131. <div class="spec">
  132. <p><tt>is_a(Id::<a href="#type-int">int()</a>, Context) -&gt; <a href="#type-atomlist">atomlist()</a></tt></p>
  133. </div><p>Return the list of categories (as atoms) that the category is part of</p>
  134. <h3 class="function"><a name="is_a-3">is_a/3</a></h3>
  135. <div class="spec">
  136. <p><tt>is_a(Id::<a href="#type-int">int()</a>, Cat, Context) -&gt; <a href="#type-atomlist">atomlist()</a></tt></p>
  137. </div><p>Check if the id is within another category.</p>
  138. <h3 class="function"><a name="last_modified-2">last_modified/2</a></h3>
  139. <div class="spec">
  140. <p><tt>last_modified(Cat::term(), Context) -&gt; {ok, {{Y, M, D}, {Hour, Min, Sec}}} | {error, Reason}</tt></p>
  141. </div><p>Return the last modification date of the category. Returns false</p>
  142. <h3 class="function"><a name="m_find_value-3">m_find_value/3</a></h3>
  143. <div class="spec">
  144. <p><tt>m_find_value(Index::Key, M::Source, Context) -&gt; term()</tt></p>
  145. </div><p>Fetch the value for the key from a model source</p>
  146. <h3 class="function"><a name="m_to_list-2">m_to_list/2</a></h3>
  147. <div class="spec">
  148. <p><tt>m_to_list(M::Source, Context) -&gt; List</tt></p>
  149. </div><p>Transform a m_config value to a list, used for template loops</p>
  150. <h3 class="function"><a name="m_value-2">m_value/2</a></h3>
  151. <div class="spec">
  152. <p><tt>m_value(M::Source, Context) -&gt; term()</tt></p>
  153. </div><p>Transform a model value so that it can be formatted or piped through filters</p>
  154. <h3 class="function"><a name="move_before-3">move_before/3</a></h3>
  155. <div class="spec">
  156. <p><tt>move_before(CatId::<a href="#type-int">int()</a>, BeforeCatId::<a href="#type-int">int()</a>, Context) -&gt; ok | {error, Reason}</tt></p>
  157. </div><p>Move a category in front of another category, resetting the parent of the moved category to
  158. the parent of the other category.</p>
  159. <h3 class="function"><a name="move_below-3">move_below/3</a></h3>
  160. <div class="spec">
  161. <p><tt>move_below(CatId::<a href="#type-int">int()</a>, NewParentId::<a href="#type-int">int()</a>, Context) -&gt; ok | {error, Reason}</tt></p>
  162. </div><p>Move the category below another category, placing it at the end of the children of that category.</p>
  163. <h3 class="function"><a name="move_end-2">move_end/2</a></h3>
  164. <div class="spec">
  165. <p><tt>move_end(CatId::<a href="#type-int">int()</a>, Context) -&gt; ok | {error, Reason}</tt></p>
  166. </div><p>Move the category to the end of all categories, making it a top category in the process</p>
  167. <h3 class="function"><a name="name_to_id-2">name_to_id/2</a></h3>
  168. <div class="spec">
  169. <p><tt>name_to_id(Id, Context) -&gt; any()</tt></p>
  170. </div>
  171. <h3 class="function"><a name="name_to_id_check-2">name_to_id_check/2</a></h3>
  172. <div class="spec">
  173. <p><tt>name_to_id_check(Name, Context) -&gt; any()</tt></p>
  174. </div>
  175. <h3 class="function"><a name="ranges-2">ranges/2</a></h3>
  176. <div class="spec">
  177. <p><tt>ranges(Cat::CatList, Context) -&gt; RangeList</tt></p>
  178. </div><p>Given a list of category ids, return the list of numeric ranges they cover.</p>
  179. <h3 class="function"><a name="renumber-1">renumber/1</a></h3>
  180. <div class="spec">
  181. <p><tt>renumber(Context) -&gt; ok</tt></p>
  182. </div><p>Renumber all categories so that the left/right and level indices are correct.</p>
  183. <h3 class="function"><a name="renumber_pivot_task-2">renumber_pivot_task/2</a></h3>
  184. <div class="spec">
  185. <p><tt>renumber_pivot_task(LowId, Context) -&gt; any()</tt></p>
  186. </div><p>Resync all ids that have their category nr changed.</p>
  187. <h3 class="function"><a name="tree-1">tree/1</a></h3>
  188. <div class="spec">
  189. <p><tt>tree(Context) -&gt; Tree</tt></p>
  190. </div><p>Return the tree of all categories</p>
  191. <h3 class="function"><a name="tree-2">tree/2</a></h3>
  192. <div class="spec">
  193. <p><tt>tree(CatId, Context) -&gt; TreeNode</tt></p>
  194. </div><p>Return the tree of all categories below a category id</p>
  195. <h3 class="function"><a name="tree_depth-2">tree_depth/2</a></h3>
  196. <div class="spec">
  197. <p><tt>tree_depth(Depth, Context) -&gt; Tree</tt></p>
  198. </div><p>Return the tree of all categories till a certain depth</p>
  199. <h3 class="function"><a name="tree_depth-3">tree_depth/3</a></h3>
  200. <div class="spec">
  201. <p><tt>tree_depth(CatId, Depth, Context) -&gt; TreeNode</tt></p>
  202. </div><p>Return the tree of all categories below a category id till a certain depth</p>
  203. <h3 class="function"><a name="update_sequence-2">update_sequence/2</a></h3>
  204. <div class="spec">
  205. <p><tt>update_sequence(Ids, Context) -&gt; any()</tt></p>
  206. </div>
  207. <hr>
  208. <div class="navbar"><a name="#navbar_bottom"></a><table width="100%" border="0" cellspacing="0" cellpadding="2" summary="navigation bar"><tr><td><a href="overview-summary.html" target="overviewFrame">Overview</a></td><td><a href="http://www.erlang.org/"><img src="erlang.png" align="right" border="0" alt="erlang logo"></a></td></tr></table></div>
  209. <p><i>Generated by EDoc, Aug 12 2011, 20:01:40.</i></p>
  210. </body>
  211. </html>