Skip to the content
Documentation
Help Start
Reading in:
  • German: 9,059 of 9,059 pages
About the help in other languages
All help pages

eZContentObjectTreeNode

The node methods extensions use - fetch(), fetchByURLPath(), subTreeByNodeID() and its parameters, subTreeCountByNodeID(), object(), path, URL alias, access - with a tested example.

Download as PDF

Address: https://doc.exponential.earth/exphelp/viewer/help/extension-development/part-8-reference/ezcontentobjecttreenode.md

On this page

eZContentObjectTreeNode

Part 8, reference 7. A node (kernel/classes/ezcontentobjecttreenode.php) is a location of a content object in the content tree. Lists, menus and paths are made of nodes. The node with ID 2 is usually the root of the site's content.

Fetching one node

Method (static)Returns
fetch( $nodeID = false, $lang = false, $asObject = true, $conditions = false )the node, or null
fetchByURLPath( $pathString, $asObject = true )the node at a URL path
fetchByContentObjectID( $contentObjectID, $asObject = true, $contentObjectVersion = false )every node of an object
fetchNode( $contentObjectID, $parentNodeID )the node of an object under a given parent

Fetching lists: subTreeByNodeID()

static function subTreeByNodeID( $params = false, $nodeID = 0 )
static function subTreeCountByNodeID( $params, $nodeID )

The parameters, in an array:

KeyMeaning
Depth, DepthOperatorhow deep: 1 with eq for direct children; lt, le and others for ranges
ClassFilterType, ClassFilterArrayinclude or exclude, with class identifiers
AttributeFilterconditions on attributes, for example array( array( 'published', '>', $since ) )
SortByarray( 'published', false ) (false = descending), or a list of such pairs
Offset, Limitpaging
Language, OnlyTranslatedtranslations
IgnoreVisibilityinclude hidden nodes
MainNodeOnlyonly main locations
LoadDataMapload the attributes at once
Limitationarray() to skip the access check (only when you check access yourself)
AsObjectfalse for plain arrays

Access policies and visibility apply unless you switch them off; that is what you want for anything shown to users. Always use the matching subTreeCountByNodeID() for paging, with the same filters.

<?php
$params = array( 'Depth' => 1, 'DepthOperator' => 'eq',
                 'ClassFilterType' => 'include', 'ClassFilterArray' => array( 'article', 'folder' ),
                 'SortBy' => array( 'published', false ),
                 'Offset' => 0, 'Limit' => 10 );
$children = eZContentObjectTreeNode::subTreeByNodeID( $params, 2 );
$total = eZContentObjectTreeNode::subTreeCountByNodeID( $params, 2 );
foreach ( $children as $child )
{
    echo $child->attribute( 'node_id' ), ' ', $child->getName(), ' /', $child->attribute( 'url_alias' ), "\n";
}

Reading a node

Method or attributeReturns
object()the content object
dataMap()the object's attributes
getName( $language = false )the name
attribute( 'url_alias' ), urlAlias()the URL path without the leading slash
fetchParent()the parent node
pathArray()the node IDs from the root to this node
children(), childrenCount( $checkPolicies = true )direct children
isMain()whether this is the object's main node
canRead(), canEdit(), canCreate(), canRemove()access of the current user

In templates

The same lists come from the fetch function fetch( 'content', 'list', hash( ... ) ) with the same parameters in lower case (parent_node_id, class_filter_type, sort_by, limit); see Built-in fetch functions.

Become an Exponential Partner

Partners share their information, provide funding, contribute back and develop the products with us, and that is how Exponential grows. A partner website and dashboard are planned for mid-2027: please become a partner today to speed up our growth rate and land new features faster.

Something wrong on this page? Report an error

Documentation license

This documentation is free documentation, licensed under the GNU Free Documentation License 1.3 or later.

Exponential Copyright © 1998-2026 Exponential Foundation and 7x