Table of Contents

assignRef

API Package Subpackage Class Method Reference Last reviewed Doc status
API Home Package Joomla.Framework Subpackage Application Class JView Method assignRef Reference assignRef() Never Work in Progress

Assigns a variable to the view by reference.

Variables should generally be assigned by reference if they are objects or complex data types. This saves on memory.

The method will not permit data to be assigned to properties that begin with an underscore because these are either private properties for JView or private variables within the template script itself.

The first parameter is the name of the variable to assign and the second parameter is the value.

This method returns true of the variable was successfully assigned, or false otherwise.

Syntax

boolean assignRef ( $key, &$val )

$key string is a string containing the name for the reference in the view.
&$val mixed is the referenced variable.

Examples

Example

$view->assignRef( 'var1', $refObject );

The object can later be accessed using:

$view->var1