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

reorder_node()

Description

Function used to reorder nodes based on an array with nodes in the new order

Parameters

ColumnTypeDefaultDescription
$nodes_new_order array Array of nodes

Return

void

Location

include/node_functions.php lines 453 to 474

Definition

 
function reorder_node(array $nodes_new_order)
    {
    if(
=== count($nodes_new_order))
        {
        
trigger_error('$nodes_new_order cannot be an empty array!');
        }

    
$order_by 10;

    
$query 'UPDATE node SET order_by = (CASE ref ';
    foreach(
$nodes_new_order as $node_ref)
        {
        
$query    .= 'WHEN \'' $node_ref '\' THEN \'' $order_by '\' ';
        
$order_by += 10;
        }
    
$query .= 'ELSE order_by END);';

    
sql_query($query);
    
clear_query_cache("schema");

    return;
    }

This article was last updated 24th November 2020 06:35 Europe/London time based on the source file dated 13th November 2020 16:50 Europe/London time.