Class ContentTreeDirective
java.lang.Object
ch.tocco.nice2.dms.impl.freemarker.ContentTreeDirective
- All Implemented Interfaces:
Nice2TemplateDirective
,freemarker.template.TemplateDirectiveModel
,freemarker.template.TemplateModel
- Direct Known Subclasses:
BreadcrumbsDirective
Parameters:
* node (String, optional, defaults to current node or root node (topLevel flag is set to true) of current
request (if any)): url of starting node
* nodeEntity (Entity, optional, alternative for setting the 'node' paramater)
* topLevel (Boolean, optional, defaults to false): set to true to start at the root node (domain) of the current request
rather than the root node of the current request (only applies if the node param is omitted)
* type (String, optional, defaults to "Page"): any node type which should be printed (e.g. Resource), or comma separated for multiple types
* provideLeafVariable (Boolean, optional, defaults to false): activates variable leaf
* recursive (Boolean, optional, defaults to false): prints map recursively (use with care; complex nested structures are not supported (e.g. ul, li, ul,...)
* renderAfterRecursive (Boolean, optional, defaults to false): if true after the rendering of the children elements the body is a second time rendered (the second time the variable 'renderAfterRecursive' is true). So elements such as ul can be closed
* ignoreVisibleInNavigation (Boolean, optional, defaults to false): set to true, to ignore the flag "isVisibleInNavigation" when loading children
Available variables:
* href (String): url
* label (String): label (name)
* title (String): title, fallback to label
* baseData (Entity): underlying entity of node (e.g. Page)
* leaf (Boolean): only available when activated with directive parameter provideLeafVariable=true
* first (Boolean): first node of level
* last (Boolean): last node of level
* active (Boolean): true for the currently requested node
* activePath (Boolean): true for any parent node of the currently requested node (i.e. its path is active)
* level (Number): the current level of the current node (the argument node has level 0)
* index (Number): the index of the current node in the current level (starting with 0)
* type (String): the type of the current node (Folder, Page, etc.)
Example code:
```xml
[@contentTree node="http://localhost:8080/"]
[#if first]
[ul]
[/#if]
[li][a href="${href}"]${label}[/a]
[@contentTree]
[#if first]
[ul]
[/#if]
[li][a href="${href}"]${label}[/a][/li]
[#if last]
[/ul]
[/#if]
[/@contentTree]
[/li]
[#if last]
[/ul]
[/#if]
[/@contentTree]
```
-
Nested Class Summary
-
Field Summary
Fields inherited from interface freemarker.template.TemplateModel
NOTHING
-
Constructor Summary
ConstructorDescriptionContentTreeDirective
(ContentTreeService contentTreeService, RequestService requestService, org.slf4j.Logger log) -
Method Summary
Modifier and TypeMethodDescriptionvoid
execute
(freemarker.core.Environment env, Map params, freemarker.template.TemplateModel[] loopVars, freemarker.template.TemplateDirectiveBody body) protected ArrayList
<ContentTreeNode> getChildren
(ContentTreeNode node, Iterable<String> nodeTypes, boolean ignoreVisibleInNavigation) protected ContentTreeDirective.DirectiveContext
getDirectiveContext
(freemarker.core.Environment env, Map params, freemarker.template.TemplateDirectiveBody body) protected String
getTitle
(ContentTreeNode node)
-
Field Details
-
requestService
-
-
Constructor Details
-
ContentTreeDirective
public ContentTreeDirective(ContentTreeService contentTreeService, RequestService requestService, org.slf4j.Logger log)
-
-
Method Details
-
execute
public void execute(freemarker.core.Environment env, Map params, freemarker.template.TemplateModel[] loopVars, freemarker.template.TemplateDirectiveBody body) throws freemarker.template.TemplateException, IOException - Specified by:
execute
in interfacefreemarker.template.TemplateDirectiveModel
- Throws:
freemarker.template.TemplateException
IOException
-
getDirectiveContext
protected ContentTreeDirective.DirectiveContext getDirectiveContext(freemarker.core.Environment env, Map params, freemarker.template.TemplateDirectiveBody body) throws ParameterException, freemarker.template.TemplateException - Throws:
ParameterException
freemarker.template.TemplateException
-
getChildren
protected ArrayList<ContentTreeNode> getChildren(ContentTreeNode node, Iterable<String> nodeTypes, boolean ignoreVisibleInNavigation) -
getTitle
- Throws:
PersistException
-