Actions

API15

JRegistry/getValue

From Joomla! Documentation

< API15:JRegistry
Revision as of 16:24, 22 March 2010 by Doxiki (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Replacement filing cabinet.png
This Namespace has been archived - Please Do Not Edit or Create Pages in this namespace. Pages contain information for a Joomla! version which is no longer supported. It exists only as a historical reference, will not be improved and its content may be incomplete.

Contents

Description

Get a registry value

[Edit Descripton]

Description:JRegistry/getValue

Syntax

getValue($regpath, $default=null)
Parameter Name Default Value Description
$regpath $regpath Registry path (e.g. joomla.content.showauthor)
$default null $default Optional default value

Returns

mixed Value of entry or null

Defined in

libraries/joomla/registry/registry.php

Importing

jimport( 'joomla.registry.registry' );

Source Body

function getValue($regpath, $default=null)
{
        $result = $default;
 
        // Explode the registry path into an array
        if ($nodes = explode('.', $regpath))
        {
                // Get the namespace
                //$namespace = array_shift($nodes);
                $count = count($nodes);
                if ($count < 2) {
                        $namespace      = $this->_defaultNameSpace;
                        $nodes[1]       = $nodes[0];
                } else {
                        $namespace = $nodes[0];
                }
 
                if (isset($this->_registry[$namespace])) {
                        $ns = & $this->_registry[$namespace]['data'];
                        $pathNodes = $count - 1;
 
                        //for ($i = 0; $i < $pathNodes; $i ++) {
                        for ($i = 1; $i < $pathNodes; $i ++) {
                                if((isset($ns->$nodes[$i]))) $ns =& $ns->$nodes[$i];
                        }
 
                        if(isset($ns->$nodes[$i])) {
                                $result = $ns->$nodes[$i];
                        }
                }
        }
        return $result;
}

[Edit See Also] SeeAlso:JRegistry/getValue

Examples

<CodeExamplesForm />