Actions

API16

JController/getView

From Joomla! Documentation

< API16:JController
Replacement filing cabinet.png
This Namespace has been archived - Please Do Not Edit or Create Pages in this namespace. Pages contain information for a Joomla! version which is no longer supported. It exists only as a historical reference, will not be improved and its content may be incomplete.

Contents

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

<CodeExamplesForm />