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

get_node_by_name()

Description

Search an array of nodes by name

Useful to avoid querying the database multiple times
if we already have a full detail array of nodes

Parameters

ColumnTypeDefaultDescription
$nodes array Nodes array as returned by get_nodes()
$name string Filter by name of node
$i18n boolean true Use the translated option value?

Return

array

Location

include/node_functions.php lines 1930 to 1955

Definition

 
function get_node_by_name(array $nodes$name$i18n true)
    {
    if(
== count($nodes) || is_null($name) || '' == trim($name))
        {
        return array();
        }

    
$name mb_strtolower($name);

    foreach(
$nodes as $node)
        {
        
$option $node['name'];

        if(
$i18n)
            {
            
$option i18n_get_translated($node['name']);
            }

        if(
$name === mb_strtolower($option))
            {
            return 
$node;
            }
        }

    return array();
    }

This article was last updated 5th December 2024 06:35 Europe/London time based on the source file dated 28th November 2024 12:10 Europe/London time.