Collections functions
Encryption functions
General functions
Render functions
Theme permission functions
Video functions
Resource functions

get_tree_node_level()

Description

Determine how many level deep a node is. Useful for knowing how much to indent a node

Parameters

ColumnTypeDefaultDescription
$ref integer Node ref

Return

integer The depth value of a tree node

Location

include/node_functions.php lines 365 to 385

Definition

 
function get_tree_node_level($ref)
    {
    if(!isset(
$ref))
        {
        
trigger_error('Node ID should be set AND NOT NULL');
        }

    
$parent      escape_check($ref);
    
$depth_level = -1;

    do
        {
        
$query  "SELECT parent AS value FROM node WHERE ref = '" $parent "';";
        
$parent sql_value($query0);

        
$depth_level++;
        }
    while(
'' != trim($parent) && $parent!=0);

    return 
$depth_level;
    }

This article was last updated 26th November 2020 03:35 Europe/London time based on the source file dated 13th November 2020 16:50 Europe/London time.