# Changes for page Tree Macro

Last modified by superadmin on 2017/11/28 14:52

#### Export

#### Office Formats

Export as PDF Export as ODT Export as RTF

#### Other Formats

Export as HTML
From empty
To version 1.1
edited by superadmin
on 2017/11/28 14:52
Change comment: Install extension [org.xwiki.platform:xwiki-platform-tree-macro/9.9]

## Summary

- Page properties (5 modified, 0 added, 0 removed)
- Objects (0 modified, 14 added, 0 removed)
  - XWiki.WikiMacroClass[0]
  - XWiki.WikiMacroParameterClass[0]
  - XWiki.WikiMacroParameterClass[1]
  - XWiki.WikiMacroParameterClass[2]
  - XWiki.WikiMacroParameterClass[3]
  - XWiki.WikiMacroParameterClass[4]
  - XWiki.WikiMacroParameterClass[5]
  - XWiki.WikiMacroParameterClass[6]
  - XWiki.WikiMacroParameterClass[7]
  - XWiki.WikiMacroParameterClass[8]
  - XWiki.WikiMacroParameterClass[9]
  - XWiki.WikiMacroParameterClass[10]
  - XWiki.WikiMacroParameterClass[11]
  - XWiki.WikiMacroParameterClass[12]

## Details

Page properties
  Title

    ... | ... | @@ -1,0 +1,1 @@
    | 1 | +Tree Macro

  Parent

    ... | ... | @@ -1,0 +1,1 @@
    | 1 | +Macros.WebHome

  Author

    ... | ... | @@ -1,1 +1,1 @@
    1 |  | -XWiki.XWikiGuest
    | 1 | +xwiki:XWiki.superadmin

  Hidden

    ... | ... | @@ -1,1 +1,1 @@
    1 |  | -false
    | 1 | +true

  Content

    ... | ... | @@ -1,0 +1,63 @@
    | 1 | +== Static tree ==
    | 2 | +
    | 3 | +{{tree}}
    | 4 | +* [[Chapter 1>>Main.WebHome]]
    | 5 | +** Section 2.1
    | 6 | +** Section 2.2
    | 7 | +*** Paragraph 2.2.1
    | 8 | +**** Once upon a time...
    | 9 | +*** Paragraph 2.2.2
    | 10 | +* [[Chapter 2>>Sandbox.WebHome]]
    | 11 | +* [[Chapter 3>>http://www.xwiki.org]]
    | 12 | +** Section 3.1
    | 13 | +*** Paragraph 3.1.1
    | 14 | +** Section 3.2
    | 15 | +{{/tree}}
    | 16 | +
    | 17 | +=== Static tree with opened path ===
    | 18 | +
    | 19 | +{{tree}}
    | 20 | +{{velocity}}
    | 21 | +{{html}}
    | 22 | +<ul>
    | 23 | + <li class="jstree-open">
    | 24 | + <a href="$xwiki.getURL('Main.WebHome')">One</a>
    | 25 | + <ul>
    | 26 | + <li class="jstree-open">
    | 27 | + <a href="http://www.xwiki.org">Two</a>
    | 28 | + <ul>
    | 29 | + <li>
    | 30 | + <a href="#section" class="jstree-clicked">Three</a>
    | 31 | + </li>
    | 32 | + </ul>
    | 33 | + </li>
    | 34 | + </ul>
    | 35 | + </li>
    | 36 | +</ul>
    | 37 | +{{/html}}
    | 38 | +{{/velocity}}
    | 39 | +{{/tree}}
    | 40 | +
    | 41 | +=== Static tree with custom icons ===
    | 42 | +
    | 43 | +{{tree}}
    | 44 | +{{html}}
    | 45 | +<ul>
    | 46 | + <li data-jstree='{"opened":true,"selected":true}'>Users
    | 47 | + <ul>
    | 48 | + <li data-jstree='{"disabled":true}'>Alice</li>
    | 49 | + <li data-jstree='{"icon":"http://jstree.com/tree.png"}'>Bob</li>
    | 50 | + <li data-jstree='{"icon":"glyphicon glyphicon-leaf"}'>Carol</li>
    | 51 | + </ul>
    | 52 | + </li>
    | 53 | +</ul>
    | 54 | +{{/html}}
    | 55 | +{{/tree}}
    | 56 | +
    | 57 | +== Dynamic Tree ==
    | 58 | +
    | 59 | +{{tree reference="XWiki.DocumentTree" /}}
    | 60 | +
    | 61 | +=== Dynamic Sub-tree with Checkboxes ===
    | 62 | +
    | 63 | +{{tree reference="doc:XWiki.DocumentTree" root="document:xwiki:Sandbox.WebHome" checkboxes="true" /}}

XWiki.WikiMacroClass[0]
  Macro code

    ... | ... | @@ -1,0 +1,15 @@
    | 1 | +{{template name="tree_macros.vm" /}}
    | 2 | +
    | 3 | +{{velocity output="false"}}
    | 4 | +#set ($options = {})
    | 5 | +#foreach ($parameterName in $xcontext.macro.params.parameterNames)
    | 6 | + #set ($discard = $options.put($parameterName, $xcontext.macro.params.get($parameterName)))
    | 7 | +#end
    | 8 | +#set ($content = $xcontext.macro.content)
    | 9 | +#if ("$!content" == '' && $xcontext.action == 'edit' && $editor == 'wysiwyg')
    | 10 | + #set ($content = "$services.icon.render('chart_organisation') $services.localization.render('tree.macro.editModeWarning')")
    | 11 | +#end
    | 12 | +#set ($output = "(% #treeAttributes($options true) %)((($!content)))")
    | 13 | +## Parse the output and return the resulting XDOM blocks.
    | 14 | +#set ($xcontext.macro.result = $services.rendering.parse($output, $xwiki.currentContentSyntaxId).children)
    | 15 | +{{/velocity}}

  Content description (Not applicable for "No content" type)

    ... | ... | @@ -1,0 +1,1 @@
    | 1 | +You can use nested HTML unordered lists to describe the tree structure. See http://www.jstree.com/docs/html/ for more information.

  Macro content type

    ... | ... | @@ -1,0 +1,1 @@
    | 1 | +Optional

  Default category

    ... | ... | @@ -1,0 +1,1 @@
    | 1 | +Navigation

  Macro description

    ... | ... | @@ -1,0 +1,1 @@
    | 1 | +Displays a tree hierarchy defined by the macro content or the source parameter.

  Macro id

    ... | ... | @@ -1,0 +1,1 @@
    | 1 | +tree

  Macro name

    ... | ... | @@ -1,0 +1,1 @@
    | 1 | +Tree

  Supports inline mode

    ... | ... | @@ -1,0 +1,1 @@
    | 1 | +No

  Macro visibility

    ... | ... | @@ -1,0 +1,1 @@
    | 1 | +Current Wiki

XWiki.WikiMacroParameterClass[0]
  Parameter description

    ... | ... | @@ -1,0 +1,1 @@
    | 1 | +The reference to the resource that describes the tree structure and its context menu and which is called to perform the actions on the tree nodes. This resource is used to load the tree dynamically (on demand) when a tree node is opened and to ask for the context menu when the user right-clicks on a tree node that has it. So the resource is not static. For static trees you should use the macro content instead. The reference can be a document reference or an URL/path.

  Parameter mandatory

    ... | ... | @@ -1,0 +1,1 @@
    | 1 | +No

  Parameter name

    ... | ... | @@ -1,0 +1,1 @@
    | 1 | +reference

XWiki.WikiMacroParameterClass[1]
  Parameter description

    ... | ... | @@ -1,0 +1,1 @@
    | 1 | +The root node id. This is useful if you want to display only the descendants of a given node (which is the specified root). The tree displays the children of the root node on the first level, so the root node is not actually displayed. The entire tree is displayed if the root node is not specified.

  Parameter mandatory

    ... | ... | @@ -1,0 +1,1 @@
    | 1 | +No

  Parameter name

    ... | ... | @@ -1,0 +1,1 @@
    | 1 | +root

XWiki.WikiMacroParameterClass[2]
  Parameter default value

    ... | ... | @@ -1,0 +1,1 @@
    | 1 | +false

  Parameter description

    ... | ... | @@ -1,0 +1,1 @@
    | 1 | +Specifies if the user should be able to drag & drop tree nodes.

  Parameter mandatory

    ... | ... | @@ -1,0 +1,1 @@
    | 1 | +No

  Parameter name

    ... | ... | @@ -1,0 +1,1 @@
    | 1 | +dragAndDrop

XWiki.WikiMacroParameterClass[3]
  Parameter default value

    ... | ... | @@ -1,0 +1,1 @@
    | 1 | +false

  Parameter description

    ... | ... | @@ -1,0 +1,1 @@
    | 1 | +Whether to show the context menu when the user right-clicks a tree node.

  Parameter mandatory

    ... | ... | @@ -1,0 +1,1 @@
    | 1 | +No

  Parameter name

    ... | ... | @@ -1,0 +1,1 @@
    | 1 | +contextMenu

XWiki.WikiMacroParameterClass[4]
  Parameter description

    ... | ... | @@ -1,0 +1,1 @@
    | 1 | +Additional CSS classes to add to the top level HTML element of the tree.

  Parameter mandatory

    ... | ... | @@ -1,0 +1,1 @@
    | 1 | +No

  Parameter name

    ... | ... | @@ -1,0 +1,1 @@
    | 1 | +class

XWiki.WikiMacroParameterClass[5]
  Parameter default value

    ... | ... | @@ -1,0 +1,1 @@
    | 1 | +true

  Parameter description

    ... | ... | @@ -1,0 +1,1 @@
    | 1 | +Whether to show the tree node icons or not. You may want to hide the icons if all the tree nodes are of the same type or if you want to win some horizontal space.

  Parameter mandatory

    ... | ... | @@ -1,0 +1,1 @@
    | 1 | +No

  Parameter name

    ... | ... | @@ -1,0 +1,1 @@
    | 1 | +icons

XWiki.WikiMacroParameterClass[6]
  Parameter default value

    ... | ... | @@ -1,0 +1,1 @@
    | 1 | +true

  Parameter description

    ... | ... | @@ -1,0 +1,1 @@
    | 1 | +Whether to show the edges that connect the sibling tree nodes between themselves and with their parent.

  Parameter mandatory

    ... | ... | @@ -1,0 +1,1 @@
    | 1 | +No

  Parameter name

    ... | ... | @@ -1,0 +1,1 @@
    | 1 | +edges

XWiki.WikiMacroParameterClass[7]
  Parameter default value

    ... | ... | @@ -1,0 +1,1 @@
    | 1 | +false

  Parameter description

    ... | ... | @@ -1,0 +1,1 @@
    | 1 | +Specifies whether the node labels should look and behave as links (anchors).

  Parameter mandatory

    ... | ... | @@ -1,0 +1,1 @@
    | 1 | +No

  Parameter name

    ... | ... | @@ -1,0 +1,1 @@
    | 1 | +links

XWiki.WikiMacroParameterClass[8]
  Parameter default value

    ... | ... | @@ -1,0 +1,1 @@
    | 1 | +false

  Parameter description

    ... | ... | @@ -1,0 +1,1 @@
    | 1 | +Whether to display a checkbox in front of each tree node to allow the user to select multiple tree nodes.

  Parameter mandatory

    ... | ... | @@ -1,0 +1,1 @@
    | 1 | +No

  Parameter name

    ... | ... | @@ -1,0 +1,1 @@
    | 1 | +checkboxes

XWiki.WikiMacroParameterClass[9]
  Parameter description

    ... | ... | @@ -1,0 +1,1 @@
    | 1 | +The id of the node to open the tree to. All the ancestors of the specified node, up to the root of the tree, will be opened also.

  Parameter mandatory

    ... | ... | @@ -1,0 +1,1 @@
    | 1 | +No

  Parameter name

    ... | ... | @@ -1,0 +1,1 @@
    | 1 | +openTo

XWiki.WikiMacroParameterClass[10]
  Parameter default value

    ... | ... | @@ -1,0 +1,1 @@
    | 1 | +false

  Parameter description

    ... | ... | @@ -1,0 +1,1 @@
    | 1 | +Show a text input that can be used to find tree nodes. The input is displayed above the tree and offers suggestions as you type based on the content of the tree. When a suggestion is selected the tree is expanded up to the corresponding node.

  Parameter mandatory

    ... | ... | @@ -1,0 +1,1 @@
    | 1 | +No

  Parameter name

    ... | ... | @@ -1,0 +1,1 @@
    | 1 | +finder

XWiki.WikiMacroParameterClass[11]
  Parameter default value

    ... | ... | @@ -1,0 +1,1 @@
    | 1 | +false

  Parameter description

    ... | ... | @@ -1,0 +1,1 @@
    | 1 | +Whether to show the root node or not. The root node is not shown by default because it is usually implied from the context where the tree is displayed (e.g. a label before the tree). There are some cases though when you may want to display the root node: to be able to create a new node under the root.

  Parameter mandatory

    ... | ... | @@ -1,0 +1,1 @@
    | 1 | +No

  Parameter name

    ... | ... | @@ -1,0 +1,1 @@
    | 1 | +showRoot

XWiki.WikiMacroParameterClass[12]
  Parameter default value

    ... | ... | @@ -1,0 +1,1 @@
    | 1 | +15

  Parameter description

    ... | ... | @@ -1,0 +1,1 @@
    | 1 | +The maximum number of child nodes to display when expanding a parent node for the first time. The rest of the child nodes are accessible through a "more ..." link. This parameter is basically used to paginate the child nodes and thus helps the tree scale when the number of child nodes is large. The tree passes this parameter to the tree source so it works only with dynamic trees whose source implements child count limit.

  Parameter mandatory

    ... | ... | @@ -1,0 +1,1 @@
    | 1 | +No

  Parameter name

    ... | ... | @@ -1,0 +1,1 @@
    | 1 | +limit

# Applications

# Tips

If you're starting with XWiki, check out the Getting Started Guide.

# Need help?

If you need help with XWiki you can contact:

- Community Support
- Professional Support