Collections functions
Encryption functions
General functions
Render functions
Theme permission functions
Video 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 1623 to 1648

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 23rd November 2020 16:05 Europe/London time based on the source file dated 13th November 2020 16:50 Europe/London time.