Collections functions
General functions
Render functions
Theme permission functions
Resource 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 5349 to 5402

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,
                      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 30th September 2022 17:35 Europe/London time based on the source file dated 22nd September 2022 11:00 Europe/London time.