Collections functions
General functions
Render 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 1787 to 1806

Definition

 
function get_parent_nodes($noderef)
    {
    
$parent_nodes=array();
    
$topnode=false;
    do
        {
        
$node=ps_query("select n.parent, pn.name from node n join node pn on pn.ref=n.parent where n.ref=?", array("i",$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 2nd October 2022 16:05 Europe/London time based on the source file dated 30th September 2022 14:20 Europe/London time.