Collections functions
Encryption functions
General functions
Render functions
Theme permission functions
Video functions
Resource functions

update_collection_order()

Description

Reorder the items in a collection using $neworder as the order by metric

Parameters

ColumnTypeDefaultDescription
$neworder array Array of columns to order by
$collection integer
$offset integer 0

Return

void

Location

include/collections_functions.php lines 2327 to 2345

Definition

 
function update_collection_order($neworder,$collection,$offset=0)
    {    
    if (!
is_array($neworder)) {
        exit (
"Error: invalid input to update collection function.");
    }

    if (
count($neworder)>0) {
        
$updatesql"update collection_resource set sortorder=(case resource ";
        
$counter $offset;
        foreach (
$neworder as $colresource){
            
$updatesql.= "when '" escape_check($colresource) . "' then '$counter' ";
            
$counter++;
        }
        
$updatesql.= "else sortorder END) WHERE collection='" escape_check($collection) . "'";
        
sql_query($updatesql);
    }
    
$updatesql="update collection_resource set sortorder=99999 WHERE collection='" escape_check($collection) . "' and sortorder is NULL";
    
sql_query($updatesql);
    }

This article was last updated 1st December 2020 08:05 Europe/London time based on the source file dated 30th November 2020 16:50 Europe/London time.