Coding standards
Security in ResourceSpace
Developer reference
Database
Action functions
Admin functions
Ajax functions
Annotation functions
API functions
Collections functions
Comment functions
Config functions
CSV export functions
Dash functions
Debug functions
Encryption functions
Facial recognition functions
File functions
General functions
Language functions
Log functions
Login functions
Message functions
Migration functions
Node functions
PDF functions
Plugin functions
Render functions
Reporting functions
Request functions
Research functions
Slideshow functions
Theme permission functions
User functions
Video functions
Database functions
Metadata functions
Resource functions
Search functions
Map functions
Job functions
Tab functions
Test 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 561 to 584

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 17th November 2024 15:35 Europe/London time based on the source file dated 28th October 2024 11:15 Europe/London time.