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

node_field_options_override()

Description

Overrides either a field[options] array structure or a flat option array with values derived from nodes.
If a field, then will also add field=>nodes[] sub array ready for field rendering.

Parameters

ColumnTypeDefaultDescription
&$field
$resource_type_field integer null ID of the metadata field, if specified will treat as flat options list
$field mixed Either field array structure or flat options list array

Return

boolean

Location

include/node_functions.php lines 976 to 1035

Definition

 
function node_field_options_override(&$field,$resource_type_field=null)
    {
    global 
$FIXED_LIST_FIELD_TYPES;
    if(isset(
$field["type"]) && !in_array($field["type"],$FIXED_LIST_FIELD_TYPES))
        {
        return 
false;
        }
    if (!
is_null($resource_type_field))     // we are dealing with a single specified resource type so simply return array of options
        
{
        
$options get_nodes($resource_type_field);
        if(
count($options) > 0)     // only override if field options found within nodes
            
{
            
$field = array();
            foreach (
$options as $option)
                {
                
array_push($field,$option['name']);
                }
            }
        return 
true;
        }

    if (
        !isset(
$field['ref']) ||
        !isset(
$field['type']) ||
        !
in_array($field['type'], array(237912))
    )
        {
        return 
false;       // get out of here if not a node supported field type
        
}

    
migrate_resource_type_field_check($field);

    
$field['nodes'] = array();          // setup new nodes associate array to be used by node-aware field renderers
    
$field['node_options'] = array();   // setup new node options list for render of flat fields such as drop down lists (saves another iteration through nodes to grab names)

    
if ($field['type'] == FIELD_TYPE_CATEGORY_TREE)
        {
        
$category_tree_nodes get_nodes($field['ref'], nullfalse);
        if (
count($category_tree_nodes) > 0)
            {
            foreach (
$category_tree_nodes as $node)
                {
                
$field['nodes'][$node['ref']] = $node;
                }
            }
        }
    else        
// normal comma separated options used for checkboxes, selects, etc.
        
{
        
$nodes get_nodes($field['ref'],null,false,null,null,null,null,(bool)$field['automatic_nodes_ordering']);
        if (
count($nodes) > 0)
            {
            foreach (
$nodes as $node)
                {
                
$field['nodes'][$node['ref']]=$node;
                
array_push($field['node_options'],$node['name']);
                }
            }
        }
    return 
true;
    }

This article was last updated 17th November 2024 15:05 Europe/London time based on the source file dated 28th October 2024 11:15 Europe/London time.