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

Definition

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

    
$parent      $ref;
    
$depth_level = -1;

    do
        {
        
$query  "SELECT parent AS value FROM node WHERE ref = ?";
        
$parameters = array("i",$parent);
        
$parent ps_value($query$parameters0);

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

    return 
$depth_level;
    }

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