m_hierarchy (zotonic_core v1.0.0-rc.17)
The category hierarchy tables have been replaced by m_hierarchy. This model defines named hierarchies of resources (pages).
If the categories are changed then the system needs to update the pivot_category_nr field of all resources. With the introduction of m_hierarchy this renumbering is much more efficient and will only affect a minimal number of resources.
The m_hierarchy module is also used for the content- and user group hierarchies, as used by the new mod_acl_user_groups module.
Available Model API Paths
| Method | Path pattern | Description |
|---|---|---|
get | /+name/tree/... | Return full hierarchy tree for hierarchy +name. |
get | /+name/tree1/... | Return first-level hierarchy tree for hierarchy +name. |
get | /+name/tree_flat/... | Return flat tree-ordered list for hierarchy +name. |
get | /+name/menu/... | Return hierarchy +name formatted as a menu tree. |
get | /+name/menu_ensured/... | Return menu hierarchy for +name, ensuring required parent nodes exist. |
get | /+name/+id/menu_ensured/... | Return menu subtree for hierarchy +name rooted at +id, ensuring missing parents are created. |
get | /+name/+id/menu/... | Return menu subtree for hierarchy +name rooted at resource +id. |
get | /+name/+id/tree/... | Return hierarchy subtree for +name rooted at resource +id. |
get | /+name/+id/tree1/... | Return first-level subtree for hierarchy +name rooted at resource +id. |
get | /+name/+id/tree_flat/... | Return flat tree-ordered list for hierarchy +name subtree rooted at resource +id. |
/+name marks a variable path segment. A trailing /... means extra path segments are accepted for further lookups.
Summary
Functions
-spec ensure(atom() | binary() | string() | integer(), #context{cowreq :: cowboy_req:req() | undefined, cowenv :: cowboy_middleware:env() | undefined, site :: atom(), controller_module :: atom() | undefined, client_id :: binary() | undefined, client_topic :: mqtt_sessions:topic() | undefined, routing_id :: binary() | undefined, acl :: term() | admin | undefined, acl_is_read_only :: boolean(), user_id :: integer() | authenticated | undefined, render_state :: undefined | z_render:render_state(), db :: {atom(), atom()} | undefined, dbc :: pid() | undefined, language :: [atom()], tz :: binary(), props :: map(), depcache :: pid() | atom(), dispatcher :: pid() | atom(), template_server :: pid() | atom(), scomp_server :: pid() | atom(), dropbox_server :: pid() | atom(), pivot_server :: pid() | atom(), module_indexer :: pid() | atom(), translation_table :: atom()}) -> {ok, integer()} | {error, term()}.
-spec ensure(atom() | binary() | string(), atom() | integer() | string(), #context{cowreq :: cowboy_req:req() | undefined, cowenv :: cowboy_middleware:env() | undefined, site :: atom(), controller_module :: atom() | undefined, client_id :: binary() | undefined, client_topic :: mqtt_sessions:topic() | undefined, routing_id :: binary() | undefined, acl :: term() | admin | undefined, acl_is_read_only :: boolean(), user_id :: integer() | authenticated | undefined, render_state :: undefined | z_render:render_state(), db :: {atom(), atom()} | undefined, dbc :: pid() | undefined, language :: [atom()], tz :: binary(), props :: map(), depcache :: pid() | atom(), dispatcher :: pid() | atom(), template_server :: pid() | atom(), scomp_server :: pid() | atom(), dropbox_server :: pid() | atom(), pivot_server :: pid() | atom(), module_indexer :: pid() | atom(), translation_table :: atom()}) -> {ok, integer()}.
-spec m_get(list(), zotonic_model:opt_msg(), z:context()) -> zotonic_model:return().