+

Search Tips   |   Advanced Search

Command reference - Tree navigation | Portal Scripting Interface

The Content, Layout, and Portlet beans each represent a tree hierarchy. The basic navigation methods are the same for all three. A tree bean provides methods to access the root node to look up the parent and children of a node, and to maintain a cursor that points to a selected node in the tree.

The code examples use the Content bean, but we can do the same operations on the other tree beans as well. The command root returns the ID of the root node, as a fixed starting point for navigation.

Jython: Content.root()

Jacl: $Content root

We can select a node by its ID using the select command. We can clear the current selection by using deselect or by using select without an argument. We can return the ID of the selected node using the current command. For interactive use, csn is an alias for current. Jython example:

Jacl example:

The path command returns a list of all IDs from the root to the currently selected node. In a similar way, the children command returns the children of the selected node. We can obtain the ID of the parent of the selected node by using parent. Jython example:

Jacl example:

We can also use the commands path, parent, and children with an explicit ID instead of implicitly referring to the currently selected node. Jython example:

Jacl example:

For simplicity, there are dedicated select commands for the root node and for the parent of the currently selected node. In the following example, the first argument is a dummy used to distinguish the method from the select with an ID argument. The dummy argument is not interpreted. The second argument is a keyword, which is not case-sensitive. Alternative, shorter keywords are documented in the bean help. Jython example:

Jacl example:

Parent topic: Command reference for the Portal Scripting Interface