JController/getView
From Joomla! Documentation
< API15:JController
The "API15" 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]
Method to get a reference to the current view and load it if necessary.
Template:Description:JController/getView
Syntax[edit]
& getView($name= '', $type= '', $prefix= '', $config=array())
Parameter Name | Default Value | Description |
---|---|---|
$name | The view name. Optional, defaults to the controller name. | |
$type | The view type. Optional. | |
$prefix | The class prefix. Optional. | |
$config | array() | Configuration array for view. Optional. |
Returns[edit]
object Reference to the view or an error.
Defined in[edit]
libraries/joomla/application/component/controller.php
Importing[edit]
jimport( 'joomla.application.component.controller' );
Source Body[edit]
function &getView( $name = '', $type = '', $prefix = '', $config = array() )
{
static $views;
if ( !isset( $views ) ) {
$views = array();
}
if ( empty( $name ) ) {
$name = $this->getName();
}
if ( empty( $prefix ) ) {
$prefix = $this->getName() . 'View';
}
if ( empty( $views[$name] ) )
{
if ( $view = & $this->_createView( $name, $prefix, $type, $config ) ) {
$views[$name] = & $view;
} else {
$result = JError::raiseError(
500, JText::_( 'View not found [name, type, prefix]:' )
. ' ' . $name . ',' . $type . ',' . $prefix
);
return $result;
}
}
return $views[$name];
}
[Edit See Also] Template:SeeAlso:JController/getView
Examples[edit]
<CodeExamplesForm />