API16

API16:JController/display

From Joomla! Documentation

Description

Typical view method for MVC based architecture


<! removed transcluded page call, red link never existed >

Syntax

display($cachable=false)
Parameter Name Default Value Description
$cachable false $cachable If true, the view output will be cached

Defined in

libraries/joomla/application/component/controller.php

Importing

jimport( 'joomla.application.component.controller' );

Source Body

public function display($cachable = false)
{
        $document = &JFactory::getDocument();

        $viewType       = $document->getType();
        $viewName       = JRequest::getCmd('view', $this->getName());
        $viewLayout     = JRequest::getCmd('layout', 'default');

        $view = & $this->getView($viewName, $viewType, '', array('base_path'=>$this->_basePath));

        // Get/Create the model
        if ($model = & $this->getModel($viewName)) {
                // Push the model into the view (as default)
                $view->setModel($model, true);
        }

        // Set the layout
        $view->setLayout($viewLayout);

        // Display the view
        if ($cachable && $viewType != 'feed') {
                global $option;
                $cache = &JFactory::getCache($option, 'view');
                $cache->get($view, 'display');
        } else {
                $view->display();
        }
}


<! removed transcluded page call, red link never existed >

Examples

Code Examples