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

Fetching nodes and lists

The content fetches for pages: node by id, path or remote id; list and tree with their parameters (parent_node_id, sort_by, offset, limit, depth, class filters, attribute filters, main_node_only, ignore_visibility…

Download as PDF

Address: https://doc.exponential.earth/exphelp/viewer/help/designers/templates/fetching-nodes-and-lists.md

On this page

Fetching nodes and lists

This page is for designers who fetch pages and lists of pages. All parameters below are from kernel/content/function_definition.php.

Contents

  1. One node
  2. Children: list
  3. Descendants: tree
  4. Counts for paging
  5. Examples

One node

{def $home = fetch( 'content', 'node', hash( 'node_id', 2 ) )}
{def $about = fetch( 'content', 'node', hash( 'node_path', 'about-us' ) )}
{def $info = fetch( 'content', 'node', hash( 'remote_id', 'mytheme-site-info' ) )}

Parameters: node_id, node_path, remote_id, language_code. The result is false when the node does not exist or may not be read.

Children: list

{def $children = fetch( 'content', 'list', hash( 'parent_node_id', $node.node_id,
                                                 'sort_by', $node.sort_array,
                                                 'class_filter_type', 'include',
                                                 'class_filter_array', array( 'article', 'blog_post' ),
                                                 'offset', $offset,
                                                 'limit', 10 ) )}
ParameterMeaning
parent_node_idwhose children (required)
sort_bysort fields (Fetch filters and sorting); $node.sort_array uses the order the editor set
offset, limitpaging
class_filter_type, class_filter_arrayinclude or exclude these class identifiers
attribute_filter, extended_attribute_filterfilter on field values or custom joins
depth, depth_operatorfor tree: how deep
main_node_onlyonly the main location of each object
ignore_visibilityinclude hidden nodes (avoid in public designs)
only_translated, languagelanguage handling
objectname_filternames starting with a letter (A to Z lists)
group_by, limitation, as_object, load_data_mapadvanced: grouping, permission override, plain arrays, whether field data is loaded at once

Descendants: tree

The same parameters, for every level below the parent; with depth to limit it:

{def $all_articles = fetch( 'content', 'tree', hash( 'parent_node_id', 2,
                                                     'class_filter_type', 'include',
                                                     'class_filter_array', array( 'article' ),
                                                     'sort_by', array( 'published', false() ),
                                                     'limit', 5 ) )}

A tree fetch over a large site is expensive: always filter by class and limit.

Counts for paging

list_count and tree_count take the same filter parameters (without sort_by, offset, limit):

{def $total = fetch( 'content', 'list_count', hash( 'parent_node_id', $node.node_id,
                                                    'class_filter_type', 'include',
                                                    'class_filter_array', array( 'article' ) ) )}

Examples

The latest three news on the front page:

{def $news_folder = fetch( 'content', 'node', hash( 'remote_id', 'mytheme-news-folder' ) )}
{if $news_folder}
    {def $latest = fetch( 'content', 'list', hash( 'parent_node_id', $news_folder.node_id,
                                                   'sort_by', array( 'published', false() ),
                                                   'limit', 3 ) )}
    {foreach $latest as $item}{node_view_gui content_node=$item view='line'}{/foreach}
    {undef $latest}
{/if}
{undef $news_folder}

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