I'm trying to follow the mvc tutorial and installed the code with extension manager.
It all works fine and dandy but I'm trying to figure out where all the rest of the page comes from. The template only prints out "Hello World" but the page is complete with menu and all.
Is there a way to only print out "Hello World"? The following shows that I can edit some file (not specified what) and have it print out JSON, it'll be invalid JSON when the output is surrounded with some sort of master page template though.
After installing the plugin I have the following files:
/components/com_helloworld/helloworld.php
<?php
// No direct access to this file
defined('_JEXEC') or die('Restricted access');
// import joomla controller library
jimport('joomla.application.component.controller');
// Get an instance of the controller prefixed by HelloWorld
$controller = JController::getInstance('HelloWorld');
// Perform the Request task
$controller->execute(JRequest::getCmd('task'));
// Redirect if set by the controller
$controller->redirect();
/components/com_helloworld/controller.php
<?php
// No direct access to this file
defined('_JEXEC') or die('Restricted access');
// import Joomla controller library
jimport('joomla.application.component.controller');
/**
* Hello World Component Controller
*/
class HelloWorldController extends JController
{
}
/components/com_helloworld/views/helloworld/view.html.php
<?php
// No direct access to this file
defined('_JEXEC') or die('Restricted access');
// import Joomla view library
jimport('joomla.application.component.view');
/**
* HTML View class for the HelloWorld Component
*/
class HelloWorldViewHelloWorld extends JView
{
// Overwriting JView display method
function display($tpl = null)
{
// Assign data to the view
$this->msg = 'Hello World';
// Display the view
parent::display($tpl);
}
}
/components/com_helloworld/views/helloworld/tmpl/default.php
<?php
// No direct access to this file
defined('_JEXEC') or die('Restricted access');
?>
<h1><?php echo $this->msg; ?></h1>
I can output something in /components/com_helloworld/helloworld.php and leave it at that but was thinking more along the way of the view to produce the output and the controller to fetch the data.