Collections functions
General functions
Node functions
Render functions
Theme permission functions
User functions
Resource functions

reorder_all_featured_collections_with_parent()

Description

Re-order all featured collections at a particular tree depth.

Parameters

ColumnTypeDefaultDescription
$parent: ?int
['i'
$sql_where_parent->parameters
c.`name`
c.`type`
c.parent
c.order_by
cr.resource countDISTINCT
array_merge['i'
COLLECTION_TYPE_FEATURED]
parent null|integer ID of the featured collections' parent to target

Return

array Featured collection IDs list, in the new order

Location

include/collections_functions.php lines 7036 to 7064

Definition

 
function reorder_all_featured_collections_with_parent(?int $parent): array
    {
    
$sql_where_parent is_null($parent)
        ? new 
PreparedStatementQuery('IS NULL')
        : new 
PreparedStatementQuery('= ?', ['i'$parent]);
    
$fcs_at_depth ps_query(
          
"SELECT DISTINCT c.ref,
                  c.`name`,
                  c.`type`,
                  c.parent,
                  c.order_by,
                  count(DISTINCT cr.resource) > 0 AS has_resources
             FROM collection AS c
        LEFT JOIN collection_resource AS cr ON c.ref = cr.collection
            WHERE c.`type` = ?
              AND c.parent 
{$sql_where_parent->sql}
         GROUP BY c.ref"
,
        
array_merge(['i'COLLECTION_TYPE_FEATURED], $sql_where_parent->parameters)
    );

    if (!
$GLOBALS['allow_fc_reorder']) {
        
$fcs_at_depth array_map('set_order_by_to_zero'$fcs_at_depth);
    }
    
usort($fcs_at_depth'order_featured_collections');
    
$new_fcs_order array_column($fcs_at_depth'ref');
    
sql_reorder_records('collection'$new_fcs_order);
    
    return 
$new_fcs_order;
    }

This article was last updated 18th May 2024 07:35 Europe/London time based on the source file dated 16th May 2024 18:10 Europe/London time.