Collections functions
Encryption functions
General functions
Render functions
Theme permission functions
Video functions
Resource functions

get_node_tree()

Description

This function returns a multidimensional array with hierarchy that reflects category tree field hierarchy, using parent and order_by fields

Parameters

ColumnTypeDefaultDescription
$parentId string "" - elements at top of tree do not have a value for "parent" field, so default value is empty string, otherwise it is the value of the parent element in tree
$nodes array array - node tree to parse and order

Return

array $tree - multidimension array containing nodes in correct hierarchical order

Location

include/node_functions.php lines 1740 to 1757

Definition

 
function get_node_tree($parentId "", array $nodes = array())
    {
    
$tree = array();
    foreach (
$nodes as $node
        {
        if(
$node["parent"] == $parentId)
            {
            
$children get_node_tree($node["ref"] , $nodes);
            if (
$children)
                {
                
uasort($children,"node_orderby_comparator"); 
                
$node["children"] = $children;
                }
            
$tree[] = $node;
            }
        }
    return 
$tree;
    }

This article was last updated 25th November 2020 07:35 Europe/London time based on the source file dated 13th November 2020 16:50 Europe/London time.