Actions

J2.5

Developing a MVC Component/Adding a view to the site part

From Joomla! Documentation

< J2.5:Developing a MVC Component
Revision as of 02:39, 3 November 2009 by Cdemko (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Documentation all together tranparent small.png
Under Construction

This article or section is in the process of an expansion or major restructuring. You are welcome to assist in its construction by editing it as well. If this article or section has not been edited in several days, please remove this template.
This article was last edited by Cdemko (talk| contribs) 4 years ago. (Purge)

Indroduction

This tutorial is part of the Developing a Model-View-Controller (MVC) Component for Joomla!1.6 tutorial. You are encouraged to read the precedent parts of the tutorial before reading this one.

In the Joomla!1.6 framework, third party components authors divide their code in three main parts:

  • models They are responsible for managing the data
  • controllers They perform tasks, set and get states of the models and ask the views to display
  • views They display the content according to the type (html, raw, pdf, ...) and the layout chosen by the controllers

Setting the controller

In the core code of Joomla, there is a class able to manage controllers: JController. This class has to be extended to be used it in our component. In the file site/helloworld.php (entry point of our Hello World component), put these lines

<?php defined(_JEXEC) or die('Restricted access');

You can test this basic component by putting index.php?option=com_helloworld in your browser address (don't forget to prefix this address by your Joomla!1.6 installation path).

Create a compressed file of this directory or directly download the archive and install it using the extension manager of Joomla!1.6. You can test this basic component by putting index.php?option=com_helloworld or administrator/index.php?option=com_helloworld in your browser address. You can also noticed that the Hello World! component is visible in the administrator site of your Joomla!1.6 installation under the Components menu.

Contributors