Collections functions
General functions
Render functions
Theme permission functions
Resource functions

cattree_node_flatten()

Description

Helper function which adds child nodes after each flattened parent node

Parameters

ColumnTypeDefaultDescription
$node array Array of nodes each with a child node array

Return

array Array of nodes with child nodes flattened out after their respective parents

Location

include/node_functions.php lines 2172 to 2186

Definition

 
function cattree_node_flatten($node) {
    
# Build node being flattened                                            
    
$flat_element = array('ref' => (string) $node['ref'],
                        
'resource_type_field' => (string) $node['resource_type_field'],
                        
'name' => (string) $node['name'],
                        
'parent' => (string) $node['parent'],
                        
'order_by' => (string) $node['order_by'],
                        
'resource' => (string) $node['resource']);
    
# Append children after flattened node                                                                
    
$cumulative_entries = array($flat_element);
    foreach(
$node['children'] as $child) {
        
$cumulative_entries array_merge($cumulative_entriescattree_node_flatten($child));
    }
    return 
$cumulative_entries;
}

This article was last updated 2nd December 2022 20:05 Europe/London time based on the source file dated 25th November 2022 11:35 Europe/London time.