API16

API16:JController/display

From Joomla! Documentation

Revision as of 22:35, 22 March 2010 by Doxiki (talk | contribs) (New page: ===Description=== Typical view method for MVC based architecture <span class="editsection" style="font-size:76%;"> <nowiki>[</nowiki>[[Description:JController/display|Edit Descripton]...)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Description

Typical view method for MVC based architecture

[Edit Descripton]

Template:Description:JController/display

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();
        }
}

[Edit See Also] Template:SeeAlso:JController/display

Examples

<CodeExamplesForm />