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 520 to 543

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 ';
    
$parameters = array();

    foreach (
$nodes_new_order as $node_ref) {
        
$query    .= 'WHEN ? THEN ? ';
        
$parameters[] = "i";
        
$parameters[] = $node_ref;
        
$parameters[] = "i";
        
$parameters[] = $order_by;
        
$order_by += 10;
    }
    
$query .= 'ELSE order_by END);';

    
ps_query($query$parameters);
    
clear_query_cache("schema");
}

This article was last updated 14th June 2025 21:35 Europe/London time based on the source file dated 9th May 2025 16:15 Europe/London time.