Actions

API16

JView/assign

From Joomla! Documentation

< API16:JView
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

Assigns variables to the view script via differing strategies.

[Edit Descripton]

Description:JView/assign

Syntax

assign()


Returns

bool True on success, false on failure.

Defined in

libraries/joomla/application/component/view.php

Importing

jimport( 'joomla.application.component.view' );

Source Body

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;
}

[Edit See Also] SeeAlso:JView/assign

Examples

<CodeExamplesForm />