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

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 7107 to 7135

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 4th December 2024 08:35 Europe/London time based on the source file dated 27th November 2024 15:30 Europe/London time.