Collections functions
General functions
Node functions
Render functions
Theme permission functions
User functions
Resource 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 1929 to 1954

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 19th March 2024 09:05 Europe/London time based on the source file dated 15th March 2024 17:00 Europe/London time.