Coding standards
Security in ResourceSpace
Developer reference
Database
Action functions
Admin functions
Ajax functions
Annotation functions
API functions
Collections functions
Comment functions
Config functions
CSV export functions
Dash functions
Debug functions
Encryption functions
Facial recognition functions
File functions
General functions
Language functions
Log functions
Login functions
Message functions
Migration functions
Node functions
PDF functions
Plugin functions
Render functions
Reporting functions
Request functions
Research functions
Slideshow functions
Theme permission functions
User functions
Video functions
Database functions
Metadata functions
Resource functions
Search functions
Map functions
Job functions
Tab functions
Test 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 1458 to 1495

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 columns_in("node","n");
        
// Add code to get translated names
        
$params = [];
        
add_sql_node_language($sql_select,$params,"n");
        }

    
$query "SELECT {$sql_select} FROM node AS n INNER JOIN resource_node AS rn ON n.ref = rn.node WHERE rn.resource = ?";
    
$params[] = 'i';$params[] = $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";
            }
        }
    else
        {
        
$query .= " ORDER BY n.resource_type_field, n.order_by ASC";
        }

    return 
$detailed ps_query($query$params) : ps_array($query$params);
    }

This article was last updated 4th December 2024 08:35 Europe/London time based on the source file dated 28th November 2024 12:10 Europe/London time.