Collections functions
General functions
Render functions
Theme permission 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 516 to 541

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");

    return;
    }

This article was last updated 20th May 2022 09:05 Europe/London time based on the source file dated 6th April 2022 16:35 Europe/London time.