Collections functions
Encryption functions
General functions
Theme permission functions
Resource functions

get_parent_nodes()

Description

Get all the parent nodes of the given node, all the way back to the top of the node tree.

Parameters

ColumnTypeDefaultDescription
$noderef integer The child node ID

Return

array Array of the parent node IDs

Location

include/node_functions.php lines 1499 to 1518

Definition

 
function get_parent_nodes($noderef)
    {
    
$parent_nodes=array();
    
$topnode=false;
    do
        {
        
$node=sql_query("select n.parent, pn.name from node n join node pn on pn.ref=n.parent where n.ref='" escape_check($noderef) . "' ");
        if(empty(
$node[0]["parent"]))
            {
            
$topnode=true;
            }
        else
            {
            
$parent_nodes[$node[0]["parent"]]=$node[0]["name"];
            
$noderef=$node[0]["parent"];
            }
        }
    while (!
$topnode);
    return 
$parent_nodes;
    }

This article was last updated 10th July 2020 19:05 Europe/London time based on the source file dated 6th July 2020 18:09 Europe/London time.