Building MVC-model-view-controller component in Joomla1.5 – Part 2

Tuesday, April 14, 2009 4:57
Posted in category Joomla, MySQL, PHP, Projects, Tutorial

This tutorial is the continuation of my previous tutorial on Building MVC-model-view-controller component in Joomla1.5 – Part 1. In this tutorial, I will talk about the directory structure of a component.

All components should be created under components folder. This applies to both administrator and user part of Joomla. A component under the root components folder is accessible to general user. This is the part of component that is available to general user. The component under components folder of administrator is available to administrator.

Ok let us see the directory structure of our feedback component.

This is the structure of user part of the component. A little explanation of file structure

1. feedback.php – This is the main file of the component. This file receives control and routes the control to other controllers.

2. controller.php – This is the main controller file. In a single controller file, this responds to the request from the user. In our case we are splitting the controllers, hence this file will only route the control to required controller.

3. controllers (folder) – This folder contains all the necessary controllers for the component. In our case, we have two controllers: category.php – for category controller and feedback.php – feedback ccontroller.

4. models(folder) – This folder stores all models, that will be required by our component.

5. views (folder)
– This folder stores all the views. This folder will contain view folder. This view will then again contain layout folder and necessary view files. Here in our case, we have a view named feedback. The tmpl folder under feedback folder contains all the layout that we will use in the component: default.php – this layout displays a simple feedback submission form. list.php – This layout will be used to list all the feedbacks received. Every view folder contains a view.html.php (or view.php). This file is the main view file. I will explain about its usage in up-coming tutorial. We don’t have view for category as we will not require user to enter the category. The selection of category will be available in the feedback view.

6. tables (folder) – This folder contains all the table definitions. In our case we have category.php and feedback.php

This tables folder can be kept in administrator side of the component too. But for our convenience, we have it in the frontend.

This is the structure of the component in administrator side. This is a little unusual structure of admin panel. In this, there is extra modules folder. This is not the standard joomla way of doing the components in admin panel and ofcourse, it does not follow MVC. This is done for our convenience.

A little explanation about the modules folder. This is nothing but a modularize version of large admin.feedback.php and admin.feedback.html.php. Actually, these files are broken down into smaller modules and kept in the module folder. This is just to manage the large chunky codes in admin panel. The actual admin.feedback.php routes the control to these modules on user request.

With this I conclude this tutorial. In this tutorial, we saw the structures of the component in both the frontend and administration panel. We splitted the main controller file to multiple controllers and we also splitted the main large admin file into modules.

In next tutorial, I will talk about the conventions we should follow to write controllers, models, tables and views. Till then happy reading! ;)

VN:F [1.8.3_1051]
Rating: 8.0/10 (1 vote cast)
VN:F [1.8.3_1051]
Rating: -1 (from 1 vote)
Building MVC-model-view-controller component in Joomla1.5 - Part 28.0101
http://www.sanjeevshrestha.com.np/wp-content/plugins/sociofluid/images/digg_32.png http://www.sanjeevshrestha.com.np/wp-content/plugins/sociofluid/images/reddit_32.png http://www.sanjeevshrestha.com.np/wp-content/plugins/sociofluid/images/stumbleupon_32.png http://www.sanjeevshrestha.com.np/wp-content/plugins/sociofluid/images/delicious_32.png http://www.sanjeevshrestha.com.np/wp-content/plugins/sociofluid/images/blogmarks_32.png http://www.sanjeevshrestha.com.np/wp-content/plugins/sociofluid/images/google_32.png http://www.sanjeevshrestha.com.np/wp-content/plugins/sociofluid/images/myspace_32.png http://www.sanjeevshrestha.com.np/wp-content/plugins/sociofluid/images/facebook_32.png http://www.sanjeevshrestha.com.np/wp-content/plugins/sociofluid/images/yahoobuzz_32.png http://www.sanjeevshrestha.com.np/wp-content/plugins/sociofluid/images/twitter_32.png
You can leave a response, or trackback from your own site.

2 Responses to “Building MVC-model-view-controller component in Joomla1.5 – Part 2”

  1. saurabh shah says:

    November 30th, 2009 at 8:56 am

    Please update the next tutorial on this soon !

    UN:F [1.8.3_1051]
    Rating: 0.0/5 (0 votes cast)
    UN:F [1.8.3_1051]
    Rating: -1 (from 1 vote)
  2. David says:

    January 22nd, 2010 at 2:57 am

    These tutorials are really good. I specifically like your diagrams. They are clear, and give an excellent overall explanation. I just wish the other tutorials were available. Are they coming?

    UN:F [1.8.3_1051]
    Rating: 0.0/5 (0 votes cast)
    UN:F [1.8.3_1051]
    Rating: 0 (from 0 votes)

Leave a Reply