AbstractView

Extends CMSObject Implements ViewInterface, \Joomla\Event\DispatcherAwareInterface

Base class for a Joomla View

abstract

Class holding methods for displaying presentation data.

since

2.5.5

package

Joomla CMS

Methods

__construct

Class constructor, overridden in descendant classes.

__construct(mixed properties = null) : mixed
inherited
since

1.7.0

Arguments

properties

mixedEither and associative array or another object to set the initial properties of the object.

Response

mixed

__toString

Magic method to convert the object to a string gracefully.

__toString() : string
inherited deprecated
since

1.7.0

deprecated

3.1.4 Classes should provide their own __toString() implementation.

Response

stringThe classname.

def

Sets a default value if not already assigned

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

1.7.0

Arguments

property

stringThe name of the property.

default

mixedThe default value.

Response

mixed

dispatchEvent

Dispatches the given event on the internal dispatcher, does a fallback to the global one.

dispatchEvent(\Joomla\Event\EventInterface event) : void
since

4.1.0

Arguments

event

\Joomla\Event\EventInterfaceThe event

display

Execute and display a template script.

display(string tpl = null) : void
abstract
since

3.0

Arguments

tpl

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

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

1.7.0

see CMSObject::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(int i = null, bool toString = true) : string
inherited deprecated
since

1.7.0

deprecated

3.1.4 JError has been deprecated

Arguments

i

intOption error index.

toString

boolIndicates if Exception objects should return their error message.

Response

stringError message

getErrors

Return all errors, if any.

getErrors() : array
inherited deprecated
since

1.7.0

deprecated

3.1.4 JError has been deprecated

Response

arrayArray of error messages.

getModel

Method to get the model object

getModel(string name = null) : \Joomla\CMS\MVC\Model\BaseDatabaseModel
since

3.0

Arguments

name

stringThe name of the model (optional)

Response

\Joomla\CMS\MVC\Model\BaseDatabaseModelThe model 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

3.0

throws

\Exception

Response

stringThe name of the model

getProperties

Returns an associative array of object properties.

getProperties(bool public = true) : array
inherited
since

1.7.0

see CMSObject::get()

Arguments

public

boolIf true, returns only the public properties.

Response

array

set

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

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

1.7.0

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 deprecated
since

1.7.0

deprecated

3.1.4 JError has been deprecated

Arguments

error

stringError message.

setModel

Method to add a model to the view. We support a multiple model single view system by which models are referenced by classname. A caveat to the classname referencing is that any classname prepended by \JModel will be referenced by the name without \JModel, eg. \JModelCategory is just Category.

setModel(\Joomla\CMS\MVC\Model\BaseDatabaseModel model, bool default = false) : \Joomla\CMS\MVC\Model\BaseDatabaseModel
since

3.0

Arguments

model

\Joomla\CMS\MVC\Model\BaseDatabaseModelThe model to add to the view.

default

boolIs this the default model?

Response

\Joomla\CMS\MVC\Model\BaseDatabaseModelThe added model.

setProperties

Set the object properties based on a named array/hash.

setProperties(mixed properties) : bool
inherited
since

1.7.0

see CMSObject::set()

Arguments

properties

mixedEither an associative array or another object.

Response

bool

Properties

document

The active document object

since

3.0

Type(s)

Document

option

The URL option for the component. It is usually passed by controller while it creates the view

since

3.0

Type(s)

string

_name

The name of the view

since

3.0

Type(s)

array

_models

Registered models

since

3.0

Type(s)

array

_defaultModel

The default model

since

3.0

Type(s)

string

_errors

An array of error messages or Exception objects.

inherited deprecated
since

1.7.0

deprecated

3.1.4 JError has been deprecated

Type(s)

array