Copyright © 2009-2015 Marc Worrell
Behaviours: zotonic_model.
Authors: Marc Worrell (marc@worrell.nl).
category() = m_rsc:resource_id() | atom() | binary() | string()
delete/3 | Delete the category, move referring pages to another category. |
ensure_hierarchy/1 | Ensure that all categories are present in the $category hierarchy. |
flush/1 | |
fold/4 | Perform a function on all resource ids in a category. |
foreach/3 | Perform a function on all resource ids in a category. |
get/2 | Get the basic properties of a category. |
get_by_name/2 | |
get_path/2 | Return the path from a root to the category. |
get_range/2 | |
get_range_by_name/2 | |
id_to_name/2 | Return the name for a given category. |
image/2 | Return a random depiction of some resource with the given category. |
insert/4 | |
is_a/2 | Return the categories (as atoms) the category is part of, including the category itself (as last member). |
is_a/3 | Check if the id is within a category. |
is_a_prim/3 | Check if a category is within another category. |
is_meta/2 | Check if a category is a meta category. |
is_tree_dirty/1 | Check if the category tree is dirty (e.g. |
is_used/2 | Check if a category is actually in use. |
last_modified/2 | Return the last modification date of the category. |
m_get/3 | Fetch the value for the key from a model source. |
menu/1 | Return the menu representation of the category tree. |
move_after/3 | Move a category after another category (on the same level). |
move_below/3 | Move a category below another category (or the root set if undefined). |
name_to_id/2 | Map a category name to an id, be flexible with the input. |
ranges/2 | Given a list of category ids, return the list of numeric ranges they cover. |
renumber/1 | Start synchronizing all resources, so that the pivot_category_nr is in sync with the category hierarchy. |
renumber_pivot_task/1 | Resync all ids that have their pivot_category_nr changed. |
tree/1 | Return the category tree, every entry is a proplist. |
tree/2 | Return the category tree from the category down. |
tree1/2 | Return the category trees below the category. |
tree2/1 | Return the category tree from the category down, max children of children. |
tree2/2 | Return the category tree from the category down, max children of children. |
tree_flat/1 | Return the flattened category tree, every entry is a proplist. |
tree_flat/2 | Return the flattened category tree, every entry is a proplist. |
tree_flat_meta/1 | Return the flattened category tree, every entry is a proplist. |
delete(Id::m_rsc:resource(), TransferId::integer() | undefined, Context::z:context()) -> ok | {error, term()}
Delete the category, move referring pages to another category. After this routine the caches are dirty and child-categories might need renumbering if a TransferId was defined and there were sub-categories.
ensure_hierarchy(Context::z:context()) -> ok | {error, renumbering}
Ensure that all categories are present in the $category hierarchy. This appends any newly found categories to the end of the category tree.
flush(Context::z:context()) -> ok
fold(Category::integer() | atom(), F::function(), Acc0::term(), Context::z:context()) -> term() | {error, term()}
Perform a function on all resource ids in a category. Order of the ids is unspecified.
foreach(Category::integer() | atom(), F::function(), Context::z:context()) -> ok | {error, term()}
Perform a function on all resource ids in a category. Order of the ids is unspecified.
get(Id::m_rsc:resource(), Context::z:context()) -> list() | undefined
Get the basic properties of a category
get_by_name(Name::category(), Context::z:context()) -> list() | undefined
get_path(Id::category(), Context::z:context()) -> [integer()]
Return the path from a root to the category. Excluding the category itself, most specific last.
get_range(Id, Context) -> any()
get_range_by_name(Name, Context) -> any()
id_to_name(Name::category(), Context::z:context()) -> atom() | undefined
Return the name for a given category.
If the category does not have a unique name will result in undefined. If the lookup is made by name, the name is checked for existence, and if not found, results in undefined.image(Cat::category(), Context::z:context()) -> integer() | undefined
Return a random depiction of some resource with the given category.
insert(ParentId::undefined | integer(), Name::binary() | atom() | string(), Props::list(), Context::z:context()) -> integer()
is_a(Id::m_rsc:resource(), Context::z:context()) -> [atom()]
Return the categories (as atoms) the category is part of, including the category itself (as last member).
is_a(Id::category(), Cat::category(), Context::z:context()) -> boolean()
Check if the id is within a category.
is_a_prim(CatId::integer(), Name::binary() | string() | atom(), Context::z:context()) -> boolean()
Check if a category is within another category. This can be used within primitive rsc routines that are not able to use the rsc caching (due to recursion).
is_meta(CatId::integer(), Context::z:context()) -> boolean()
Check if a category is a meta category. This can't use the m_rsc routines as it is also used to determine the default content group during the m_rsc:get/2
is_tree_dirty(Context::z:context()) -> boolean()
Check if the category tree is dirty (e.g. resource pivot numbers are being updated)
is_used(Category, Context) -> any()
Check if a category is actually in use.
last_modified(Cat::category(), Context::z:context()) -> {ok, calendar:datetime()} | {error, term()}
Return the last modification date of the category. Returns false
m_get(Rest::list(), Msg::zotonic_model:opt_msg(), Context::z:context()) -> zotonic_model:return()
Fetch the value for the key from a model source
menu(Context::z:context()) -> [{integer(), list()}]
Return the menu representation of the category tree.
move_after(Cat::category(), After::category() | undefined, Context::z:context()) -> ok | {error, notfound}
Move a category after another category (on the same level).
move_below(Cat::integer(), Parent::integer(), Context::z:context()) -> ok | {error, notfound}
Move a category below another category (or the root set if undefined)
name_to_id(Id::m_rsc:resource() | {m_rsc:resource_id()}, Context::z:context()) -> {ok, m_rsc:resource_id()} | {error, {unknown_category, term()}}
Map a category name to an id, be flexible with the input
ranges(Cat::category() | [category()], Context::z:context()) -> [{integer(), integer()}]
Given a list of category ids, return the list of numeric ranges they cover.
renumber(Context::z:context()) -> ok
Start synchronizing all resources, so that the pivot_category_nr is in sync with the category hierarchy.
renumber_pivot_task(Context::z:context()) -> ok | {delay, integer()}
Resync all ids that have their pivot_category_nr changed.
tree(Context::z:context()) -> [list()]
Return the category tree, every entry is a proplist.
tree(Cat::category(), Context::z:context()) -> list() | undefined
Return the category tree from the category down
tree1(Cat::category(), Context::z:context()) -> list() | undefined
Return the category trees below the category
tree2(Context::z:context()) -> list() | undefined
Return the category tree from the category down, max children of children
tree2(Cat::category(), Context::z:context()) -> list() | undefined
Return the category tree from the category down, max children of children
tree_flat(Context::z:context()) -> [list()]
Return the flattened category tree, every entry is a proplist. Used for select lists.
tree_flat(CatId::category(), Context::z:context()) -> [list()]
Return the flattened category tree, every entry is a proplist. Used for select lists.
tree_flat_meta(Context::z:context()) -> [list()]
Return the flattened category tree, every entry is a proplist. Used for select lists.
Generated by EDoc