MVC in Joomla




  1. require_once( JPATH_COMPONENT.DS.’controller.php’ );
    JPATH_COMPONENT is the absolute path to the current component.
    DS is the directory separator of your system
  2.  Controller class extends JController and override display method
  3. View Claa extends Jview
    1. class HelloViewHello extends JView
        function display($tpl = null)
            $greeting = "Hello World!";
            $this->assignRef( 'greeting', $greeting );
  4. Last step is to create a template:
    // No direct access
    defined('_JEXEC') or die('Restricted access'); ?>
    <h1><?php echo $this->greeting; ?></h1> 
    Original Article   We can also add model and use database in model.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s