Skip to content

Add a new element to the tree

Benjamin Kaiser edited this page Apr 15, 2021 · 6 revisions

You can use the "add()" method of the class to add a new element to the tree:

mixed add ( integer $parent , string $title , [ integer $position = false] )

| integer | $parent | The ID of the parent node. Use "0" to add a topmost node. | | string | $title | The title of the node. | | integer | $position | (Optional) The position the node will have among the parent node's children nodes.

When parent node is given as "0", this refers to the position the node will have among the topmost nodes.

The values are 0-based, meaning that if you want the node to be inserted as the first child of the target node, you have to use "0", if you want it to be second, use "1", and so on.

If not given (or given as boolean FALSE), the node will be inserted as the last of the parent node's children nodes. |

Return: Returns the ID of the newly inserted node or FALSE on error.

Clone this wiki locally