Collections functions
Encryption functions
General functions
Render functions
Theme permission functions
Video 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 1527 to 1546

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) . "' ""schema");
        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 30th November 2020 19:35 Europe/London time based on the source file dated 30th November 2020 09:45 Europe/London time.