m_category (zotonic_core v1.0.0-rc.12)
Link to this section Summary
Functions
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 that all categories are present in the $category hierarchy. This appends any newly found categories to the end of the category tree.
Perform a function on all resource ids in a category. Order of the ids is unspecified.
Perform a function on all resource ids in a category. Order of the ids is unspecified.
Get the basic properties of a category
Return the path from a root to the category. Excluding the category itself, most specific last.
Return the name for a given category.
Return a random depiction of some resource with the given category.
Return the categories (as atoms) the category is part of, including the category itself (as last member).
Check if the id is within a category.
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).
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
Check if the category tree is dirty (e.g. resource pivot numbers are being updated)
Check if a category is actually in use.
Return the last modification date of the category. Returns false
Fetch the value for the key from a model source
Return the menu representation of the category tree.
Move a category after another category (on the same level).
Move a category below another category (or the root set if undefined)
Map a category name to an id, be flexible with the input
Given a list of category ids, return the list of numeric ranges they cover.
Start synchronizing all resources, so that the pivot_category_nr is in sync with the category hierarchy.
Resync all ids that have their pivot_category_nr changed.
Return the category trees below the category
Return the category tree from the category down, max children of children
Return the category tree from the category down, max children of children
Return the category tree, every entry is a proplist.
Return the category tree from the category down
Return the flattened category tree, every entry is a proplist. Used for select lists.
Return the flattened category tree, every entry is a proplist. Used for select lists.
Return the flattened category tree, every entry is a proplist. Used for select lists.
Link to this section Types
Link to this type
category/0
-type category() :: m_rsc:resource() | atom() | binary() | string() | {m_rsc:resource_id()}.
Link to this section Functions
Link to this function
delete(Id, TransferId, Context)
-spec delete(m_rsc:resource(), integer() | undefined, z:context()) -> ok | {error, term()}.
Link to this function
ensure_hierarchy(Context)
-spec ensure_hierarchy(z:context()) -> ok | {error, renumbering}.
Link to this function
flush(Context)
-spec flush(z:context()) -> ok.
Link to this function
fold(Category, F, Acc0, Context)
-spec fold(Category :: integer() | atom(), function(), term(), z:context()) -> term() | {error, term()}.
Link to this function
foreach(Category, F, Context)
-spec foreach(Category :: integer() | atom(), function(), z:context()) -> ok | {error, term()}.
Link to this function
get(Id, Context)
-spec get(m_rsc:resource(), z:context()) -> list() | undefined.
Link to this function
get_by_name(Name, Context)
Link to this function
get_path(Id, Context)
Link to this function
get_range(Id, Context)
Link to this function
get_range_by_name(Name, Context)
Link to this function
id_to_name(Name, Context)
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.
Link to this function
image(Cat, Context)
Link to this function
insert(ParentId, Name, Props, Context)
-spec insert(undefined | integer(), binary() | atom() | string(), list(), z:context()) -> integer().
Link to this function
is_a(Id, Context)
-spec is_a(m_rsc:resource(), z:context()) -> [atom()].
Link to this function
is_a(Id, Cat, Context)
Link to this function
is_a_prim(CatId, Name, Context)
-spec is_a_prim(m_rsc:resource_id(), binary() | string() | atom(), z:context()) -> boolean().
Link to this function
is_meta(CatId, Context)
-spec is_meta(integer(), z:context()) -> boolean().
Link to this function
is_tree_dirty(Context)
-spec is_tree_dirty(z:context()) -> boolean().
Link to this function
is_used(Category, Context)
Link to this function
last_modified(Cat, Context)
-spec last_modified(category(), z:context()) -> {ok, calendar:datetime()} | {error, term()}.
Link to this function
m_get(Rest, Msg, Context)
-spec m_get(list(), zotonic_model:opt_msg(), z:context()) -> zotonic_model:return().
Link to this function
move_after(Cat, After, Context)
Link to this function
move_below(Cat, Parent, Context)
-spec move_below(integer(), integer(), z:context()) -> ok | {error, notfound}.
Link to this function
name_to_id(Id, Context)
-spec name_to_id(category(), z:context()) -> {ok, m_rsc:resource_id()} | {error, {unknown_category, term()}}.
Link to this function
ranges(Cat, Context)
Link to this function
renumber(Context)
-spec renumber(z:context()) -> ok.
Link to this function
renumber_pivot_task(Context)
-spec renumber_pivot_task(z:context()) -> ok | {delay, integer()}.
Link to this function
tree1(Cat, Context)
Link to this function
tree2(Context)
-spec tree2(z:context()) -> list() | undefined.
Link to this function
tree2(Cat, Context)
Link to this function
tree(Context)
-spec tree(z:context()) -> [list()].
Link to this function
tree(Cat, Context)
Link to this function
tree_flat(Context)
-spec tree_flat(z:context()) -> [list()].
Link to this function
tree_flat(CatId, Context)
Link to this function
tree_flat_meta(Context)
-spec tree_flat_meta(z:context()) -> [list()].