API15

Difference between revisions of "JRegistry/setValue"

From Joomla! Documentation

< API15:JRegistry
(New page: ===Description=== Set a registry value <span class="editsection" style="font-size:76%;"> <nowiki>[</nowiki>Edit Descripton<nowiki>]</nowiki> </span...)
 
m (removing red link to edit, no existant pages)
Line 3: Line 3:
  
 
<span class="editsection" style="font-size:76%;">
 
<span class="editsection" style="font-size:76%;">
<nowiki>[</nowiki>[[Description:JRegistry/setValue|Edit Descripton]]<nowiki>]</nowiki>
+
<nowiki>[<! removed edit link to red link >]</nowiki>
 
</span>
 
</span>
  
{{Description:JRegistry/setValue}}
+
<! removed transcluded page call, red link never existed >
  
 
===Syntax===
 
===Syntax===
Line 80: Line 80:
  
 
<span class="editsection" style="font-size:76%;">
 
<span class="editsection" style="font-size:76%;">
<nowiki>[</nowiki>[[SeeAlso:JRegistry/setValue|Edit See Also]]<nowiki>]</nowiki>
+
<nowiki>[<! removed edit link to red link >]</nowiki>
 
</span>
 
</span>
{{SeeAlso:JRegistry/setValue}}
+
<! removed transcluded page call, red link never existed >
  
 
===Examples===
 
===Examples===
Line 95: Line 95:
 
  format= ,,,
 
  format= ,,,
 
</dpl>
 
</dpl>
 +
[[Category:Archived pages API15]]

Revision as of 13:43, 12 May 2013

The "API15" namespace is an archived namespace. This page contains information for a Joomla! version which is no longer supported. It exists only as a historical reference, it will not be improved and its content may be incomplete and/or contain broken links.

Description[edit]

Set a registry value

[<! removed edit link to red link >]

<! removed transcluded page call, red link never existed >

Syntax[edit]

setValue($regpath, $value)
Parameter Name Default Value Description
$regpath $regpath Registry Path (e.g. joomla.content.showauthor)
$value $value Value of entry

Returns[edit]

mixed Value of old value or boolean false if operation failed

Defined in[edit]

libraries/joomla/registry/registry.php

Importing[edit]

jimport( 'joomla.registry.registry' );

Source Body[edit]

function setValue($regpath, $value)
{
        // Explode the registry path into an array
        $nodes = explode('.', $regpath);

        // Get the namespace
        $count = count($nodes);

        if ($count < 2) {
                $namespace = $this->_defaultNameSpace;
        } else {
                $namespace = array_shift($nodes);
                $count--;
        }

        if (!isset($this->_registry[$namespace])) {
                $this->makeNameSpace($namespace);
        }

        $ns = & $this->_registry[$namespace]['data'];

        $pathNodes = $count - 1;

        if ($pathNodes < 0) {
                $pathNodes = 0;
        }

        for ($i = 0; $i < $pathNodes; $i ++)
        {
                // If any node along the registry path does not exist, create it
                if (!isset($ns->$nodes[$i])) {
                        $ns->$nodes[$i] = new stdClass();
                }
                $ns =& $ns->$nodes[$i];
        }

        // Get the old value if exists so we can return it
        $ns->$nodes[$i] =& $value;

        return $ns->$nodes[$i];
}

[<! removed edit link to red link >] <! removed transcluded page call, red link never existed >

Examples[edit]

<CodeExamplesForm />