J1.5

Difference between revisions of "Developing a MVC Component/Creating an Administrator Interface"

From Joomla! Documentation

< J1.5:Developing a MVC Component
Line 35: Line 35:
 
  <root>/administrator/components/com_hello
 
  <root>/administrator/components/com_hello
  
Guest users and registered users will enter your site via the ''default root''of the website:
+
Guest users and registered users will enter your site via the ''default root'' of the website:
 
  <root>/index.php
 
  <root>/index.php
 
Administrator users will have to login and after logging in they will enter your site via:
 
Administrator users will have to login and after logging in they will enter your site via:
 
  <root>/administrator/index.php
 
  <root>/administrator/index.php
  
With the different access points it is easy to grasp that with setting up the administrator section the naming conventions have no dependency with the site section. Whilst the MVC pattern is also applicable for the administrator section this implies that identical Controls, Views and Models naming can (and sometimes must) be used as in the site section.  
+
With the different access points it is easy to grasp that with setting up the administrator section the naming conventions have no dependency with the site section. Whilst the MVC pattern is also applicable for the administrator section this implies that identical Controls, Views and Models naming can (and sometimes must) be used as in the site section.
  
 
=== Tutorial specific naming ===
 
=== Tutorial specific naming ===

Revision as of 05:08, 11 August 2009

The "J1.5" namespace is an archived namespace. This page contains information for a Joomla! version which is no longer supported. It exists only as a historical reference, it will not be improved and its content may be incomplete and/or contain broken links.

Introduction[edit]

In the first three tutorials, we have developed a MVC component that retrieves its data from a table in the database. Currently, there is no way to add data to the database except to do it manually using another tool. In the next articles of this tutorial, we will develop an administrator section for our component which will make it possible to manage the entries in the database.

This article will be an article with no new source code for our Hello component but we will go into some basic details of the MVC pattern. In the frontend solution (site section) we have developed the first part of our component. The frontend solution is based upon default Controllers, Views and Templates and you were taken by the hand to trust the default handling of the code. This is going to change in the Backend or Administration section of our Hello component.

Site / Admin[edit]

Joomla! is a content management system. The frontend is used for presenting the users with content, the backend is responsible for administrating the website framework (structuring / managing / controlling / maintaining). This deviation in presentation and administration is the fundamental of the Joomla! architecture.

Sidestep: registered users are frontend content managers. They are allowed to change and add content but are not allowed to modify the structure of the website.

Enterance points[edit]

From the XML file of our frontend example it was already obvious that there would be an administration part:

<?xml version="1.0" encoding="utf-8"?>
  ...
  <administration>
  <!--  Administration Menu Section --> 
  <menu>Hello World!</menu> 
  <!--  Administration Main File Copy Section --> 
  <files folder="admin">
  <filename>hello.php</filename> 
  <filename>index.html</filename> 
  <filename>install.sql</filename> 
  <filename>uninstall.sql</filename> 
  </files>
  </administration>
  ...

Only the .sql files were of use and only during installation for our frontend view, the other two files have no content besides generating a blank page. Browsing on your site will reveal that our Hello component is to be found twice:

<root>/components/com_hello
<root>/administrator/components/com_hello

Guest users and registered users will enter your site via the default root of the website:

<root>/index.php

Administrator users will have to login and after logging in they will enter your site via:

<root>/administrator/index.php

With the different access points it is easy to grasp that with setting up the administrator section the naming conventions have no dependency with the site section. Whilst the MVC pattern is also applicable for the administrator section this implies that identical Controls, Views and Models naming can (and sometimes must) be used as in the site section.

Tutorial specific naming[edit]

Within the next articles the explanation of this administrator section we will keep as close as possible to the component name. For the general overview, lists from the database, we will use Hellos as identification. The Hellos naming will be used for viewing and controlling multiple Hellos at once from the database. When selecting a single Hello for Editing or Adding we will use the singular Hello as naming for the Controller and View. This Admin Hello has no functional relation with the Site Hello (the only dependency is the database content of cause).

MVC pattern interaction[edit]

Conclusion[edit]

The basic interactions of the MVC pattern are clarified and we are ready to develop the admin section.

Articles in this Series[edit]

Developing a Model-View-Controller Component - Part 1

Developing a Model-View-Controller Component - Part 2 - Adding a Model

Developing a Model-View-Controller Component - Part 3 - Using the Database

Developing a Model-View-Controller Component - Part 4 - Creating an Administrator Interface

Developing a Model-View-Controller Component - Part 5 - Basic Backend Framework

Developing a Model-View-Controller Component - Part 6 - Adding Backend Actions

Contributors[edit]

  • staalanden
  • jamesconroyuk

Download[edit]

The component can be downloaded at: com_hello4_01