Collections functions
General functions
Node functions
Render functions
Theme permission functions
User 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 546 to 569

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 19th March 2024 02:05 Europe/London time based on the source file dated 15th March 2024 17:00 Europe/London time.