API15:JController/getView
From Joomla! Documentation
Description
Method to get a reference to the current view and load it if necessary.
[<! removed edit link to red link >]
<! removed transcluded page call, red link never existed >
Syntax
& 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
object Reference to the view or an error.
Defined in
libraries/joomla/application/component/controller.php
Importing
jimport( 'joomla.application.component.controller' );
Source Body
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];
}
[<! removed edit link to red link >] <! removed transcluded page call, red link never existed >
Examples
Code Examples