Joomla! CMS 3.3 API

JViewLegacy

Extends \JObject

Base class for a Joomla View

Class holding methods for displaying presentation data.

package

Joomla.Legacy

subpackage

View

since

12.2

Methods

__construct

Class constructor, overridden in descendant classes.

__construct(mixed $properties = null) 
inherited
since

11.1

Arguments

$properties

mixedEither and associative array or another

                         object to set the initial properties of the object.

__toString

Magic method to convert the object to a string gracefully.

__toString() : string
inherited
since

11.1

deprecated

12.3 Classes should provide their own __toString() implementation.

Response

stringThe classname.

_addPath

Adds to the search path for templates and resources.

_addPath(string $type, mixed $path) : void
since

12.2

Arguments

$type

stringThe type of path to add.

$path

mixedThe directory or stream, or an array of either, to search.

_createFileName

Create the filename for a resource

_createFileName(string $type, array $parts = array()) : string
since

12.2

Arguments

$type

stringThe resource type to create the filename for

$parts

arrayAn associative array of filename information

Response

stringThe filename

_setPath

Sets an entire array of search paths for templates or resources.

_setPath(string $type, mixed $path) : void
since

12.2

Arguments

$type

stringThe type of path to set, typically 'template'.

$path

mixedThe new search path, or an array of search paths. If null or false, resets to the current directory only.

addHelperPath

Adds to the stack of helper script paths in LIFO order.

addHelperPath(mixed $path) : void
since

12.2

Arguments

$path

mixedA directory path or an array of paths.

addTemplatePath

Adds to the stack of view script paths in LIFO order.

addTemplatePath(mixed $path) : void
since

12.2

Arguments

$path

mixedA directory path or an array of paths.

assign

Assigns variables to the view script via differing strategies.

assign() : boolean

This method is overloaded; you can assign all the properties of an object, an associative array, or a single value by name.

You are not allowed to set variables that begin with an underscore; these are either private properties for JView or private variables within the template script itself.

$view = new JView;

// Assign directly $view->var1 = 'something'; $view->var2 = 'else';

// Assign by name and value $view->assign('var1', 'something'); $view->assign('var2', 'else');

// Assign by assoc-array $ary = array('var1' => 'something', 'var2' => 'else'); $view->assign($obj);

// Assign by object $obj = new stdClass; $obj->var1 = 'something'; $obj->var2 = 'else'; $view->assign($obj);

deprecated

13.3 Use native PHP syntax.

Response

booleanTrue on success, false on failure.

assignRef

Assign variable for the view (by reference).

assignRef(string $key,  &$val) : boolean

You are not allowed to set variables that begin with an underscore; these are either private properties for JView or private variables within the template script itself.

$view = new JView;

// Assign by name and value $view->assignRef('var1', $ref);

// Assign directly $view->ref = &$var1;

since

12.2

deprecated

13.3 Use native PHP syntax.

Arguments

$key

stringThe name for the reference in the view.

$val

Response

booleanTrue on success, false on failure.

def

Sets a default value if not alreay assigned

def(string $property, mixed $default = null) : mixed
inherited
since

11.1

Arguments

$property

stringThe name of the property.

$default

mixedThe default value.

Response

mixed

display

Execute and display a template script.

display(string $tpl = null) : mixed
see \JViewLegacy::loadTemplate()
since

12.2

Arguments

$tpl

stringThe name of the template file to parse; automatically searches through the template paths.

Response

mixedA string if successful, otherwise a Error object.

escape

Escapes a value for output in a view script.

escape(mixed $var) : mixed

If escaping mechanism is either htmlspecialchars or htmlentities, uses \$_encoding setting.

since

12.2

Arguments

$var

mixedThe output to escape.

Response

mixedThe escaped value.

get

Returns a property of the object or the default value if the property is not set.

get(string $property, mixed $default = null) : mixed
inherited
since

11.1

see \JObject::getProperties()

Arguments

$property

stringThe name of the property.

$default

mixedThe default value.

Response

mixedThe value of the property.

getError

Get the most recent error message.

getError(integer $i = null, boolean $toString = true) : string
inherited
since

11.1

see \JError
deprecated

12.3 JError has been deprecated

Arguments

$i

integerOption error index.

$toString

booleanIndicates if JError objects should return their error message.

Response

stringError message

getErrors

Return all errors, if any.

getErrors() : array
inherited
since

11.1

see \JError
deprecated

12.3 JError has been deprecated

Response

arrayArray of error messages or JErrors.

getForm

Returns the form object

getForm() : mixed
since

3.2

Response

mixedA JForm object on success, false on failure

getLayout

Get the layout.

getLayout() : string

Response

stringThe layout name

getLayoutTemplate

Get the layout template.

getLayoutTemplate() : string

Response

stringThe layout template name

getModel

Method to get the model object

getModel(string $name = null) : mixed
since

12.2

Arguments

$name

stringThe name of the model (optional)

Response

mixedJModelLegacy object

getName

Method to get the view name

getName() : string

The model name by default parsed using the classname, or it can be set by passing a $config['name'] in the class constructor

since

12.2

throws

\Exception

Response

stringThe name of the model

getProperties

Returns an associative array of object properties.

getProperties(boolean $public = true) : array
inherited
since

11.1

see \JObject::get()

Arguments

$public

booleanIf true, returns only the public properties.

Response

array

loadHelper

Load a helper file

loadHelper(string $hlp = null) : void
since

12.2

Arguments

$hlp

stringThe name of the helper source file automatically searches the helper paths and compiles as needed.

loadTemplate

Load a template file -- first look in the templates folder for an override

loadTemplate(string $tpl = null) : string
since

12.2

throws

\Exception

Arguments

$tpl

stringThe name of the template source file; automatically searches the template paths and compiles as needed.

Response

stringThe output of the the template script.

set

Modifies a property of the object, creating it if it does not already exist.

set(string $property, mixed $value = null) : mixed
inherited
since

11.1

Arguments

$property

stringThe name of the property.

$value

mixedThe value of the property to set.

Response

mixedPrevious value of the property.

setError

Add an error message.

setError(string $error) : void
inherited
since

11.1

see \JError
deprecated

12.3 JError has been deprecated

Arguments

$error

stringError message.

setEscape

Sets the _escape() callback.

setEscape(mixed $spec) : void
since

12.2

deprecated

13.3 Override JViewLegacy::escape() instead.

Arguments

$spec

mixedThe callback for _escape() to use.

setLayout

Sets the layout name to use

setLayout(string $layout) : string
since

12.2

Arguments

$layout

stringThe layout name or a string in format