Joomla Security

We will protect your Joomla website from malicious attack. Read more...

Site Admin

We will doing regular admin for your website, including regular backup, joomla update, joomla extensions install/update, security and optimization. Read more...

PSD to Joomla

You doing the design, I convert it into Joomla site. Read more...
Home Joomla Customization Joomla MVC Component
Joomla MVC Component

In Joomla 1.5, the MVC pattern is implemented using three classes:

  • JModule - defined in /libraries/joomla/application/component/model.php
  • JView - defined in /libraries/joomla/application/component/view.php
  • JController - defined in /libraries/joomla/application/component/controller.php

A basic component only require file files:

  • xxx.php - this is the entry point to the component.
  • controller.php - this file contains base controller.
  • views/xxx/view.html.php - this file retrieves the necessary data and pushes it into the template.
  • views/xxx/tmpl/default.php - this is the template for the output.
  • xxx.xml - this is an XML file that tells Joomla how to install the component.

For a complete MVC component, require these additional files:

  • models/xxx.php - this is the model file.
  • install.sql
  • uninstall.sql

xxx.php

// Require the base controller require_once(JPATH_COMPONENT.DS.'controller.php'); // Create the controller $controller = new XxxController(); // Perform the Request task $controller->execute(JRequest::getVar('task')); // Redirect if set by the controller $controller->redirect();

views/xxx/view.html.php

class XxxViewXxx extends JView { function display($tpl = null) { $model = &$this->getModel(); ...... parent::display($tpl); } }
 
Joomla template made by HeJian