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

MethodPath patternDescription
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

append(Name0, Missing, Context)

assign_nrs(Diff, OldFlatNr)

children(Name, Id, Context)

contains/3

ensure(Category, Context)

-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()}.

ensure/3

-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()}.

flush(Name, Context)

m_get/3

parents/3

save(Name, Tree, Context)

save_nocheck(Name, NewTree, Context)

tree1/2

tree/2

tree_flat(Name, Context)

tree_flat(Name, Id, Context)