Coding standards
Security in ResourceSpace
Developer reference
Database
Action functions
Admin functions
Ajax functions
Annotation functions
API functions
Collections functions
Comment functions
Config functions
CSV export functions
Dash functions
Debug functions
Encryption functions
Facial recognition functions
File functions
General functions
Language functions
Log functions
Login functions
Message functions
Migration functions
Node functions
PDF functions
Plugin functions
Render functions
Reporting functions
Request functions
Research functions
Slideshow functions
Theme permission functions
User functions
Video functions
Database functions
Metadata functions
Resource functions
Search functions
Map functions
Job functions
Tab functions
Test 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 2047 to 2064

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 15th December 2024 09:35 Europe/London time based on the source file dated 11th December 2024 22:35 Europe/London time.