Collections functions
General functions
Render functions
Theme permission functions
Resource functions

get_resource_nodes()

Description

Get nodes associated with a particular resource for all / a specific field (optionally)

Parameters

ColumnTypeDefaultDescription
$resource integer
$resource_type_field integer null
$detailed boolean false Set to true to return full node details (as get_node() does)
$node_sort boolean null Set to SORT_ASC to sort nodes ascending, SORT_DESC sort nodes descending, null means do not sort

Return

array

Location

include/node_functions.php lines 1471 to 1507

Definition

 
function get_resource_nodes($resource$resource_type_field null$detailed false$node_sort null)
    {
    
$sql_select 'n.ref AS `value`';
    if(
$detailed)
        {
        
$sql_select 'n.ref, n.resource_type_field, n.`name`, n.parent, n.order_by';
        }

    
$query "SELECT {$sql_select} FROM node AS n INNER JOIN resource_node AS rn ON n.ref = rn.node WHERE rn.resource = ?";
    
$params = ['i'$resource];

    if(!
is_null($resource_type_field) && is_numeric($resource_type_field))
        {
        
$query .= " AND n.resource_type_field = ?";
        
$params[] = 'i';
        
$params[] = $resource_type_field;
        }

    if(!
is_null($node_sort))
        {
        if(
$node_sort == SORT_ASC)
            {
            
$query .= " ORDER BY n.ref ASC";
            }
        if(
$node_sort == SORT_DESC)
            {
            
$query .= " ORDER BY n.ref DESC";
            }
        }

    if(
$detailed)
        {
        return 
ps_query($query$params);
        }

    return 
ps_array($query$params);
    }

This article was last updated 5th October 2022 12:35 Europe/London time based on the source file dated 3rd October 2022 13:50 Europe/London time.