JView/assign
From Joomla! Documentation
< API16:JView
The "API16" 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]
Assigns variables to the view script via differing strategies.
Syntax[edit]
assign()
Returns[edit]
bool True on success, false on failure.
Defined in[edit]
libraries/joomla/application/component/view.php
Importing[edit]
jimport( 'joomla.application.component.view' );
Source Body[edit]
function assign()
{
// get the arguments; there may be 1 or 2.
$arg0 = @func_get_arg(0);
$arg1 = @func_get_arg(1);
// assign by object
if (is_object($arg0))
{
// assign public properties
foreach (get_object_vars($arg0) as $key => $val)
{
if (substr($key, 0, 1) != '_') {
$this->$key = $val;
}
}
return true;
}
// assign by associative array
if (is_array($arg0))
{
foreach ($arg0 as $key => $val)
{
if (substr($key, 0, 1) != '_') {
$this->$key = $val;
}
}
return true;
}
// assign by string name and mixed value.
// we use array_key_exists() instead of isset() becuase isset()
// fails if the value is set to null.
if (is_string($arg0) && substr($arg0, 0, 1) != '_' && func_num_args() > 1)
{
$this->$arg0 = $arg1;
return true;
}
// $arg0 was not object, array, or string.
return false;
}
Examples[edit]
Code Examples[edit]