Collections functions
General functions
Node functions
Render functions
Theme permission functions
User functions
Resource functions

get_smart_themes_nodes()

Description

get_smart_themes_nodes

Parameters

ColumnTypeDefaultDescription
$field integer
$is_category_tree boolean
$parent integer null
$field_meta array array - resource type field metadata

Return

array

Location

include/collections_functions.php lines 1889 to 1955

Definition

 
function get_smart_themes_nodes($field$is_category_tree$parent null, array $field_meta = array())
    {
    
$return = array();

    
// Determine if this should cascade onto children for category tree type
    
$recursive false;
    if(
$is_category_tree)
        {
        
$recursive true;
        }

    
$nodes get_nodes($field, ((== $parent) ? null $parent), $recursive);

    if(isset(
$field_meta['automatic_nodes_ordering']) && (bool) $field_meta['automatic_nodes_ordering'])
                {
                
$nodes reorder_nodes($nodes);
                
$nodes array_values($nodes); // reindex nodes array
                
}

    if(
=== count($nodes))
        {
        return 
$return;
        }
  
    
/*
    Tidy list so it matches the storage format used for keywords
    The translated version is fetched as each option will be indexed in the local language version of each option
    */
    
$options_base = array();
    for(
$n 0$n count($nodes); $n++)
        {
        
$options_base[$n] = trim(mb_convert_case(i18n_get_translated($nodes[$n]['name']), MB_CASE_LOWER'UTF-8'));
        }
    
    
// For each option, if it is in use, add it to the return list
    
for($n 0$n count($nodes); $n++)
        {
        
$cleaned_option_base preg_replace('/\W/',' ',$options_base[$n]);      // replace any non-word characters with a space
        
$cleaned_option_base trim($cleaned_option_base);      // trim (just in case prepended / appended space characters)

        
$tree_node_depth    0;
        
$parent_node_to_use 0;
        
$is_parent          false;

        if(
is_parent_node($nodes[$n]['ref']))
            {
            
$parent_node_to_use $nodes[$n]['ref'];
            
$is_parent          true;

            
$tree_node_depth get_tree_node_level($nodes[$n]['ref']);

            if(!
is_null($parent) && is_parent_node($parent))
                {
                
$tree_node_depth--;
                }
            }

        
$c                       count($return);
        
$return[$c]['name']      = trim(i18n_get_translated($nodes[$n]['name']));
        
$return[$c]['indent']    = $tree_node_depth;
        
$return[$c]['node']      = $parent_node_to_use;
        
$return[$c]['is_parent'] = $is_parent;
        
$return[$c]['ref'] = $nodes[$n]['ref'];
        }

    return 
$return;
    }

This article was last updated 19th March 2024 10:35 Europe/London time based on the source file dated 15th March 2024 17:00 Europe/London time.