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_featured_collections()

Description

Get all featured collections by parent node

then considered a featured collection category and won't have any resources associated with it.

Parameters

ColumnTypeDefaultDescription
$parent integer The ref of the parent collection. When a featured collection contains another collection, it is
$ctx array Contextual data (e.g disable access control). This param MUST NOT get exposed over the API

Return

array List of featured collections (with data)

Location

include/collections_functions.php lines 5517 to 5571

Definition

 
function get_featured_collections(int $parent, array $ctx)
    {
    if(
$parent 0)
        {
        return array();
        }
    
$access_control = (isset($ctx["access_control"]) && is_bool($ctx["access_control"]) ? $ctx["access_control"] : true);


    
$params=array("i",COLLECTION_TYPE_FEATURED);
    if (
$parent==0)
        {
        
// When searching for parent '0' we're looking for a null value on the parent column denoting the top level of the featured collection tree.
        
$parentquery="IS NULL";
        }
    else
        {
        
// Numeric parent value.
        
$parentquery="=?";$params[]="i";$params[]=$parent;
        }

    
$allfcs ps_query("SELECT DISTINCT c.ref,
                      c.`name`,
                      c.`type`,
                      c.parent,
                      c.thumbnail_selection_method,
                      c.bg_img_resource_ref,
                      c.order_by,
                      c.created,
                      c.savedsearch,
                      count(DISTINCT cr.resource) > 0 AS has_resources,
                      count(DISTINCT cc.ref) > 0 AS has_children
                 FROM collection AS c
            LEFT JOIN collection_resource AS cr ON c.ref = cr.collection
            LEFT JOIN collection AS cc ON c.ref = cc.parent
                WHERE c.`type` = ?
                  AND c.parent 
$parentquery
             GROUP BY c.ref
             ORDER BY c.order_by"
,$params);

    if(!
$access_control)
        {
        return 
$allfcs;
        }

    
$validcollections = array();
    foreach(
$allfcs as $fc)
        {
        if(
featured_collection_check_access_control($fc["ref"]))
            {
            
$validcollections[]=$fc;
            }
        }
    return 
$validcollections;
    }

This article was last updated 8th December 2024 10:05 Europe/London time based on the source file dated 4th December 2024 16:35 Europe/London time.