When no task is given in the request variables, the default task will be executed. The default task is display. The JControllerLegacy class has such a task. When display is used, the 'view' variable will decide what will be displayed.

view.html.php

class HelloWorldViewHelloWorld extends JViewLegacy
{
function display($tpl = null)
{
// Assign data to the view
$this->msg = 'Hello World';

// Display the view
parent::display($tpl);
}
}

The view sets up the text to be output and then calls the base display class. JViewLegacy is a base class for a Joomla View. In current example, this method will display data using the tmpl/default.php file.

default.php

<h1><?php echo $this->msg; ?></h1>

This template file will be included by the JViewLegacy class. Therefore, here, $this refers to the HelloWorldViewHelloWorld class.

Methods in HtmlView

This class has methods for displaying presentation data.

__construct(array $config = array())

addHelperPath(mixed $path) : void

addTemplatePath(mixed $path) : void

display(string $tpl = null) : mixed

escape(mixed $var) : mixed

get(string $property, string $default = null) : mixed

getForm() : mixed

getLayout() : string

getLayoutTemplate() : string

getModel(string $name = null) : mixed

getName() : string

loadHelper(string $hlp = null) : void

loadTemplate(string $tpl = null) : string

setDocumentTitle(string $title) : void

setLayout(string $layout) : string