/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
- <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
- <html>
- <head>
- <title>Module m_category</title>
- <link rel="stylesheet" type="text/css" href="stylesheet.css" title="EDoc">
- </head>
- <body bgcolor="white">
- <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>
- <hr>
- <h1>Module m_category</h1>
- <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.
- <p>Copyright 2009 Marc Worrell
- Date: 2009-04-08
- </p>
- <p><b>Behaviours:</b> <a href="gen_model.html"><tt>gen_model</tt></a>.</p>
- <p><b>Authors:</b> Marc Worrell (<a href="mailto:marc@worrell.nl"><tt>marc@worrell.nl</tt></a>).</p>
- <h2><a name="description">Description</a></h2>Model for categories. Add, change and re-order categories.
- <h2><a name="index">Function Index</a></h2>
- <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>
- <tr><td valign="top"><a href="#all_flat-2">all_flat/2</a></td><td></td></tr>
- <tr><td valign="top"><a href="#all_flat_meta-1">all_flat_meta/1</a></td><td></td></tr>
- <tr><td valign="top"><a href="#boundaries-2">boundaries/2</a></td><td></td></tr>
- <tr><td valign="top"><a href="#delete-3">delete/3</a></td><td>Delete the category, move referring pages to another category.</td></tr>
- <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>
- <tr><td valign="top"><a href="#get-2">get/2</a></td><td></td></tr>
- <tr><td valign="top"><a href="#get_by_name-2">get_by_name/2</a></td><td></td></tr>
- <tr><td valign="top"><a href="#get_by_parent-2">get_by_parent/2</a></td><td></td></tr>
- <tr><td valign="top"><a href="#get_page_count-2">get_page_count/2</a></td><td></td></tr>
- <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>
- <tr><td valign="top"><a href="#get_range-2">get_range/2</a></td><td></td></tr>
- <tr><td valign="top"><a href="#get_range_by_name-2">get_range_by_name/2</a></td><td></td></tr>
- <tr><td valign="top"><a href="#get_root-1">get_root/1</a></td><td></td></tr>
- <tr><td valign="top"><a href="#id_to_name-2">id_to_name/2</a></td><td></td></tr>
- <tr><td valign="top"><a href="#image-2">image/2</a></td><td></td></tr>
- <tr><td valign="top"><a href="#insert-4">insert/4</a></td><td></td></tr>
- <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>
- <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>
- <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>
- <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>
- <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>
- <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>
- <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
- the parent of the other category.</td></tr>
- <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>
- <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>
- <tr><td valign="top"><a href="#name_to_id-2">name_to_id/2</a></td><td></td></tr>
- <tr><td valign="top"><a href="#name_to_id_check-2">name_to_id_check/2</a></td><td></td></tr>
- <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>
- <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>
- <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>
- <tr><td valign="top"><a href="#tree-1">tree/1</a></td><td>Return the tree of all categories.</td></tr>
- <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>
- <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>
- <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>
- <tr><td valign="top"><a href="#update_sequence-2">update_sequence/2</a></td><td></td></tr>
- </table>
- <h2><a name="functions">Function Details</a></h2>
- <h3 class="function"><a name="all_flat-1">all_flat/1</a></h3>
- <div class="spec">
- <p><tt>all_flat(Context) -> any()</tt></p>
- </div><p>Return a flattened representation of the complete category tree. Can be used for overviews or select boxes.
- The "meta" categories of predicate, category and group are suppressed.</p>
- <h3 class="function"><a name="all_flat-2">all_flat/2</a></h3>
- <div class="spec">
- <p><tt>all_flat(CatId, Context) -> any()</tt></p>
- </div>
- <h3 class="function"><a name="all_flat_meta-1">all_flat_meta/1</a></h3>
- <div class="spec">
- <p><tt>all_flat_meta(Context) -> any()</tt></p>
- </div>
- <h3 class="function"><a name="boundaries-2">boundaries/2</a></h3>
- <div class="spec">
- <p><tt>boundaries(CatId::Id, Context::C) -> {Left, Right}</tt></p>
- </div>
- <h3 class="function"><a name="delete-3">delete/3</a></h3>
- <div class="spec">
- <p><tt>delete(Id::<a href="#type-int">int()</a>, TransferId::<a href="#type-int">int()</a>, Context) -> ok | {error, Reason}</tt></p>
- </div><p>Delete the category, move referring pages to another category. Fails when the transfer id is not a category.</p>
- <h3 class="function"><a name="enumerate-1">enumerate/1</a></h3>
- <div class="spec">
- <p><tt>enumerate(Cats::[Cat]) -> [Sort]</tt>
- <ul class="definitions"><li><tt>Cat = {CatId, Parent, NodeSeq}</tt></li>
- <li><tt>Sort = {CatId, Nr, Level, Left, Right, Path}</tt></li>
- </ul></p>
- </div><p>Take a category list and make it into a tree, recalculating the left/right and lvl nrs</p>
- <h3 class="function"><a name="get-2">get/2</a></h3>
- <div class="spec">
- <p><tt>get(Name, Context) -> any()</tt></p>
- </div>
- <h3 class="function"><a name="get_by_name-2">get_by_name/2</a></h3>
- <div class="spec">
- <p><tt>get_by_name(Name, Context) -> any()</tt></p>
- </div>
- <h3 class="function"><a name="get_by_parent-2">get_by_parent/2</a></h3>
- <div class="spec">
- <p><tt>get_by_parent(Id, Context) -> any()</tt></p>
- </div>
- <h3 class="function"><a name="get_page_count-2">get_page_count/2</a></h3>
- <div class="spec">
- <p><tt>get_page_count(Id, Context) -> any()</tt></p>
- </div>
- <h3 class="function"><a name="get_path-2">get_path/2</a></h3>
- <div class="spec">
- <p><tt>get_path(Id, Context) -> [CatId]</tt></p>
- </div><p>Return the path from a root to the category (excluding the category itself)</p>
- <h3 class="function"><a name="get_range-2">get_range/2</a></h3>
- <div class="spec">
- <p><tt>get_range(Id, Context) -> any()</tt></p>
- </div>
- <h3 class="function"><a name="get_range_by_name-2">get_range_by_name/2</a></h3>
- <div class="spec">
- <p><tt>get_range_by_name(Name, Context) -> any()</tt></p>
- </div>
- <h3 class="function"><a name="get_root-1">get_root/1</a></h3>
- <div class="spec">
- <p><tt>get_root(Context) -> any()</tt></p>
- </div>
- <h3 class="function"><a name="id_to_name-2">id_to_name/2</a></h3>
- <div class="spec">
- <p><tt>id_to_name(Name, Context) -> any()</tt></p>
- </div>
- <h3 class="function"><a name="image-2">image/2</a></h3>
- <div class="spec">
- <p><tt>image(Id, Context) -> any()</tt></p>
- </div>
- <h3 class="function"><a name="insert-4">insert/4</a></h3>
- <div class="spec">
- <p><tt>insert(ParentId, Name, Props, Context) -> any()</tt></p>
- </div>
- <h3 class="function"><a name="is_a-2">is_a/2</a></h3>
- <div class="spec">
- <p><tt>is_a(Id::<a href="#type-int">int()</a>, Context) -> <a href="#type-atomlist">atomlist()</a></tt></p>
- </div><p>Return the list of categories (as atoms) that the category is part of</p>
- <h3 class="function"><a name="is_a-3">is_a/3</a></h3>
- <div class="spec">
- <p><tt>is_a(Id::<a href="#type-int">int()</a>, Cat, Context) -> <a href="#type-atomlist">atomlist()</a></tt></p>
- </div><p>Check if the id is within another category.</p>
- <h3 class="function"><a name="last_modified-2">last_modified/2</a></h3>
- <div class="spec">
- <p><tt>last_modified(Cat::term(), Context) -> {ok, {{Y, M, D}, {Hour, Min, Sec}}} | {error, Reason}</tt></p>
- </div><p>Return the last modification date of the category. Returns false</p>
- <h3 class="function"><a name="m_find_value-3">m_find_value/3</a></h3>
- <div class="spec">
- <p><tt>m_find_value(Index::Key, M::Source, Context) -> term()</tt></p>
- </div><p>Fetch the value for the key from a model source</p>
- <h3 class="function"><a name="m_to_list-2">m_to_list/2</a></h3>
- <div class="spec">
- <p><tt>m_to_list(M::Source, Context) -> List</tt></p>
- </div><p>Transform a m_config value to a list, used for template loops</p>
- <h3 class="function"><a name="m_value-2">m_value/2</a></h3>
- <div class="spec">
- <p><tt>m_value(M::Source, Context) -> term()</tt></p>
- </div><p>Transform a model value so that it can be formatted or piped through filters</p>
- <h3 class="function"><a name="move_before-3">move_before/3</a></h3>
- <div class="spec">
- <p><tt>move_before(CatId::<a href="#type-int">int()</a>, BeforeCatId::<a href="#type-int">int()</a>, Context) -> ok | {error, Reason}</tt></p>
- </div><p>Move a category in front of another category, resetting the parent of the moved category to
- the parent of the other category.</p>
- <h3 class="function"><a name="move_below-3">move_below/3</a></h3>
- <div class="spec">
- <p><tt>move_below(CatId::<a href="#type-int">int()</a>, NewParentId::<a href="#type-int">int()</a>, Context) -> ok | {error, Reason}</tt></p>
- </div><p>Move the category below another category, placing it at the end of the children of that category.</p>
- <h3 class="function"><a name="move_end-2">move_end/2</a></h3>
- <div class="spec">
- <p><tt>move_end(CatId::<a href="#type-int">int()</a>, Context) -> ok | {error, Reason}</tt></p>
- </div><p>Move the category to the end of all categories, making it a top category in the process</p>
- <h3 class="function"><a name="name_to_id-2">name_to_id/2</a></h3>
- <div class="spec">
- <p><tt>name_to_id(Id, Context) -> any()</tt></p>
- </div>
- <h3 class="function"><a name="name_to_id_check-2">name_to_id_check/2</a></h3>
- <div class="spec">
- <p><tt>name_to_id_check(Name, Context) -> any()</tt></p>
- </div>
- <h3 class="function"><a name="ranges-2">ranges/2</a></h3>
- <div class="spec">
- <p><tt>ranges(Cat::CatList, Context) -> RangeList</tt></p>
- </div><p>Given a list of category ids, return the list of numeric ranges they cover.</p>
- <h3 class="function"><a name="renumber-1">renumber/1</a></h3>
- <div class="spec">
- <p><tt>renumber(Context) -> ok</tt></p>
- </div><p>Renumber all categories so that the left/right and level indices are correct.</p>
- <h3 class="function"><a name="renumber_pivot_task-2">renumber_pivot_task/2</a></h3>
- <div class="spec">
- <p><tt>renumber_pivot_task(LowId, Context) -> any()</tt></p>
- </div><p>Resync all ids that have their category nr changed.</p>
- <h3 class="function"><a name="tree-1">tree/1</a></h3>
- <div class="spec">
- <p><tt>tree(Context) -> Tree</tt></p>
- </div><p>Return the tree of all categories</p>
- <h3 class="function"><a name="tree-2">tree/2</a></h3>
- <div class="spec">
- <p><tt>tree(CatId, Context) -> TreeNode</tt></p>
- </div><p>Return the tree of all categories below a category id</p>
- <h3 class="function"><a name="tree_depth-2">tree_depth/2</a></h3>
- <div class="spec">
- <p><tt>tree_depth(Depth, Context) -> Tree</tt></p>
- </div><p>Return the tree of all categories till a certain depth</p>
- <h3 class="function"><a name="tree_depth-3">tree_depth/3</a></h3>
- <div class="spec">
- <p><tt>tree_depth(CatId, Depth, Context) -> TreeNode</tt></p>
- </div><p>Return the tree of all categories below a category id till a certain depth</p>
- <h3 class="function"><a name="update_sequence-2">update_sequence/2</a></h3>
- <div class="spec">
- <p><tt>update_sequence(Ids, Context) -> any()</tt></p>
- </div>
- <hr>
- <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>
- <p><i>Generated by EDoc, Aug 12 2011, 20:01:40.</i></p>
- </body>
- </html>