Collections functions
Encryption functions
General functions
Theme permission 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 - node tree to parse and order

Return

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

Location

include/node_functions.php lines 1712 to 1729

Definition

 
function get_node_tree($parentId "", array $nodes)
    {
    
$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 15th July 2020 05:35 Europe/London time based on the source file dated 6th July 2020 18:09 Europe/London time.