Collections functions
Encryption functions
General 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 1269 to 1303

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.*';
        }

    
$query "SELECT {$sql_select} FROM node AS n INNER JOIN resource_node AS rn ON n.ref = rn.node WHERE rn.resource = '" escape_check($resource) . "'";

    if(!
is_null($resource_type_field) && is_numeric($resource_type_field))
        {
        
$query .= " AND n.resource_type_field = '" escape_check($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 
sql_query($query);
        }

    return 
sql_array($query);
    }

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