Collections functions
Encryption functions
General functions
Theme permission functions
Resource functions

get_node_order_by()

Description

Calculate the next order by for a new record

Parameters

ColumnTypeDefaultDescription
$resource_type_field integer ID of the metadata field
$is_tree boolean FALSE Param to flag whether this is for a tree node
$parent integer NULL ID of the parent of this node

Return

integer $order_by

Location

include/node_functions.php lines 637 to 660

Definition

 
function get_node_order_by($resource_type_field$is_tree FALSE$parent NULL)
    {
    
$order_by 10;

    
$query         "SELECT COUNT(*) AS value FROM node WHERE resource_type_field = '" escape_check($resource_type_field) . "' ORDER BY order_by ASC;";
    
$nodes_counter sql_value($query0);

    if(
$is_tree)
        {
        
$query sprintf('SELECT COUNT(*) AS value FROM node WHERE resource_type_field = \'%s\' AND %s ORDER BY order_by ASC;',
            
escape_check($resource_type_field),
            (
trim($parent)=="") ? 'parent IS NULL' 'parent = \'' escape_check($parent) . '\''
        
);

        
$nodes_counter sql_value($query0);
        }

    if(
$nodes_counter)
        {
        
$order_by = ($nodes_counter 1) * 10;
        }

    return 
$order_by;
    }

This article was last updated 10th July 2020 01:05 Europe/London time based on the source file dated 6th July 2020 18:09 Europe/London time.