Collections functions
General functions
Node functions
Render functions
Theme permission functions
User 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 2223 to 2237

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 19th March 2024 02:35 Europe/London time based on the source file dated 15th March 2024 17:00 Europe/London time.