MMBase taglib documentation

tree related tags

 

These are the MMBase tags which relate to `tree' like structures in MMBase. The core tag of this set is the tree tag itself. With the tree-tag you can present arbitrary deeply nested structures in HTML.

The following example demonstrates how to use tree's in mmbase taglib

<mm:import externid="node" required="true" />
<mm:node number="$node">

  <%-- the current node is used as a 'starting query', so this node itself will also be listed by mm:tree --%>

  <mm:treecontainer path="posrel,categories,object" searchdirs="destination">
    <%-- the query will be extended with posrel,categories, and then with any objects related to the categories,
         and then with any 'posrel' related categories related to those object etc.
    --%>

    <%-- the categories must be order according to the 'pos' field in the posrel. --%>
    <mm:sortorder field="posrel.pos" />

    <%-- don't do every category, but only those with 'a' in their title --%>
    <mm:constraint field="categories.title" operator="LIKE" value="%a%" />

    <%-- also some trivial sortorder on the 'object' steps --%>
    <mm:sortorder  field="object.number" direction="up" />

    In this tree <mm:size /> objects are presented.

    <mm:tree>

      <%-- If the current node provided by the tree is on the end of a 'longer branch', then we start a
           ul. mm:grow is iterated zero (if the previous node was _bigger or equal_) or one (if the previous
           node was _smaller_  times. (Because in a forward tree iteration the branch can not grow faster
           than that)
           --%>
      <mm:grow>
        <ul>
        <%-- we also say now already what should happen if it later 'shrinks' again. The body of this will be temporary
             put onto a stack until it is taken of it by the mm:shrink tag. -->
        <mm:onshrink></ul></mm:onshrink>
      </mm:grow>

      <%-- a tree tag provides 'real' nodes, so in the body we can show this node --%>

      <li><mm:nodeinfo type="guitype" />: <mm:field name="number" /> <mm:function name="gui" escape="none" />

      <mm:onshrink></li></mm:onshrink>

      <%-- mm:shrink will use what was put onto the 'shrink tag' by the mm:onshrink tags. The body of mm:shrink
      will be called zero (if the next node will be bigger then the current one) or more times. How
      often it iterates depends on how often mm:onshrink was called. It will be emptied until the top element
      of the shrink tag correspends to a depth which is smaller then the current depth.
      --%>

      <mm:shrink />
    </mm:tree>

  </mm:treecontainer>
</mm:node>

Trees which do not need such complicated sort orders or constraints can also be used stand-alone.

 

depth | grow | leafconstraints | onshrink | shrink | tree | treecontainer
complete table of contents
info about the syntax of this document
toc
<mm:depth> Provides the current depth of the tree. The current depth is defined by the surrounding `grow' or `shrink' tag (if present) or the `tree' tag itself otherwise. (since: MMBase-1.7)
see alsotree related tags
attributes
contextreader attributes
contextwriter attributes
contextreferrer attributes
writer attributes
toc
<mm:grow> Iterates from previous depth to (not inclusive) current depth. On the first iteration of mm:tree this will iterate one time. Currently there are not upside down trees implemented, which means that this tag now always iterates one or zero times. (since: MMBase-1.7)
see alsotree related tags | shrink
attributes
contextreader attributes
contextwriter attributes
contextreferrer attributes
toc
<mm:leafconstraints>

Lives in a tree-container tag. Constraints inside this tag are not defined as normal tree constraints but as 'leaf' constraint, which means that they are only taken into constraint on the 'leafs' of the tree.

Practically, this means that it can be used to search a tree.

(since: MMBase-1.8.0)
see alsotree related tags | querycontainerreferrer
attributes
  • on
    Decides whether the leaf-constraint is going to work on the template, or on the trunk.
    template The constraints in this tag will be applied on all the new branches of the tree when they are still 'leafs', so it applies to the template for that (determined by the attributes of treecontainer)
    trunk The constraints in this tag will be applied to the trunk query, which is normally defined by the surrounding nodequery container of the treecontainer. This makes it possible to also consider the trunk when searing a tree.
attributes
contextreader attributes
contextwriter attributes
contextreferrer attributes
toc
<mm:onshrink> The body of the tag is remembered for use by the shrink tag, used when shrinking to current depth. See depth-tag for what `current depth' means. This tag iterates from previous depth to current current depth (like grow), but the body is remembered, not executed. (since: MMBase-1.7)
see alsotree related tags | depth | shrink
attributes
contextreader attributes
contextwriter attributes
contextreferrer attributes
toc
<mm:shrink> Iterates from previous depth to (inclusive) current depth. For each depth it provides (as a writer) what was defined with `onshrink'. (since: MMBase-1.7)
see alsotree related tags | tree | onshrink | grow
attributes
contextreader attributes
contextwriter attributes
contextreferrer attributes
writer attributes
toc
<mm:tree>

The Tree Tag makes it possible to show a piece of the MMBase cloud generically. This tag never works alone. Firstly, it will try to find a surrounding `treecontainer' tag, which defines the `starting query' and other the properties of this tree. If there is no surrounding tree-container tag, then it can also use one of the other node list containers (relatednodescontainer and listnodescontainer) to define the `starting' query. If also that does not succeed then it will start looking for any surrounding node-provider (such as relatednodes, listnodes and node) and will use the provided node as a base for the starting query of the tree.

If you want to define the surrounding node-provider with a container, then you can use the 'node' attribute to enforce it to use the node-provider and not it's container.

(since: MMBase-1.7)
see alsotree related tags | treecontainer | relatednodescontainer | listnodescontainer | nodeprovider
attributes
  • type
    The tree will grow with path-elements of this type.
    see: type attribute of relatednodes
  • role
    The path-elements will be connected by relations with this role.
    see: role attribute of relatednodes
  • searchdir
    This is the directions in which the relations must be followed (destination or source).
    see: searchdir attribute of relatednodes
  • maxdepth
    To avoid coming into an infinite loop (which is possible because mmbase data is not actually structured as a tree, but as a `network' of nodes), there should always be a `maximal' depth to which relations are followed. This defaults to 5.
    see: orderby attribute of treecontainer
  • orderby (since: MMBase-1.7.1)
    It is possible to order the elements of a level of a tree by using the `orderby' field. If you wish to order using the fieldvalue of the relation from one level to another, prefix the field with the builder name or role(for example: "categories.title" or "posrel.pos"). You can order by more fields, by comma-separating their names.
    see: orderby attribute of list
  • directions (since: MMBase-1.7.1)
    Sort orders for the `orderby' arguments (comma separated `up' and `down'). This list may be shorter than the list of `orderby'. Missing directions are defaulted to the last specified one.
    see: directions attribute of list
  • max (since: MMBase-1.8.1)
    see: max attribute of list
  • varStatus (since: MMBase-1.8.6)
    see: varStatus attribute of listprovider
  • varBranchStatus (since: MMBase-1.8.6)
    This provides information about the current looping status of the current branch. If e.g. you want to know if the current node is the last of the 'branch', then you could use 'varBranchStatus="branch"'> ... ${branch.last}.
    see: varStatus attribute of listprovider
querycontainerreferrer attributes
containerreferrer attributes
nodeprovider attributes
listprovider attributes
nodereferrer attributes
contextreader attributes
contextwriter attributes
contextreferrer attributes
toc
<mm:treecontainer>

The treecontainer tag is a the `container' tag for the tree-tag. It searches on the same way as the tree tag itself for a `starting query', the only difference being that it will not itself look for a surrounding tree-container (so, it will look parent node-list-containers and if unsuccessfully for a parent node-providers).

Just as for example in the relatednodescontainer the attributes define how the `starting' query must be extended. The essential difference for `trees' though, is that it will happen recursively. So the surrounding querycontainerreferrer tags like `mm:constraint' will work only on a kind of `template' query, and will then be applied repeatedly.

The use of treecontainer, tree and its subtags can perhaps most easily be explained by an example, which can be find on the page about tree related tags.

(since: MMBase-1.7.1)
see alsotree related tags | querycontainerreferrer
attributes
querycontainerreferrer attributes
containerreferrer attributes
contextreader attributes
contextwriter attributes
contextreferrer attributes
nodereferrer attributes
 

This document lists the current tags implemented for MMBase (version )

Attributes in red are required.

blue entries are no tags, but describe a group of tags. Tags can belong to several groups.

If a tag definition contains a body section this means that the tag might do something with the content of the body.