Collections functions
Encryption functions
General functions
Render functions
Theme permission functions
Video 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 4420 to 4465

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);

    
$allfcs sql_query(
        
sprintf(
              
"SELECT DISTINCT c.ref,
                      c.`name`,
                      c.`type`,
                      c.parent,
                      c.thumbnail_selection_method,
                      c.bg_img_resource_ref,
                      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` = %s
                  AND c.parent %s
             GROUP BY c.ref"
,
            
COLLECTION_TYPE_FEATURED,
            
sql_is_null_or_eq_val((string) $parent$parent == 0)
            )
        );

    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 20th January 2021 20:05 Europe/London time based on the source file dated 19th January 2021 16:15 Europe/London time.