|
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.
|