API16

JController/display

From Joomla! Documentation

< API16:JController
Revision as of 21:56, 12 May 2013 by JoomlaWikiBot (talk | contribs) (removing red link to edit, no existant pages)

The "API16" 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]

Typical view method for MVC based architecture

[<! removed edit link to red link >]

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

Syntax[edit]

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

Defined in[edit]

libraries/joomla/application/component/controller.php

Importing[edit]

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

Source Body[edit]

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 edit link to red link >] <! removed transcluded page call, red link never existed >

Examples[edit]

<CodeExamplesForm />