phpeveryday.com

The best tutorial of php, php framework, php strategies, object oriented oriented,


Joomla MVC: How to Implement MVC Pattern in Joomla?

Tag: joomla, MVC, component, module, pattern   Category: PHP Framework
post: 10 Jan 2008 read: 3,278


Joomla MVC Step by Step Tutorial: We have known Model View Controller (MVC) at previous tutorial. In this post, we will learn more how to apply MVC in Joomla conceptually. We must understand it before write line codes. How structure file when use MVC?

We still use hello component as study case. You can read about creating Hello Joomla Component in this site for refreshing before read this. Are you ready?

First, we glance over following structure file:

MVC structure file in Joomla

Model

We must create a folder named models. We know, model task connecting with data access. We will create 2 file: all and individual display. All means show all data/more than one data in a screen. Individual display means just one data will display according id that we choose. Create two file named "all.php" for fetch list data from table and "hello.php" for single data.

Model structure file in Joomla

View

As we know, the task of View is extracts data and formats it for presentation. For this job, we need structure file model like following screen:

View structure file in Joomla

Within all folder, created file named "view.html.php". Do it again within hello folder. Next, in each tmpl folder, created file named "default.php". So we get following structure:


view
+ all
    - view.html.php
    + tmpl
        - default.php
+ hello
    - view.html.php
    + tmpl
        - default.php

Controller

We just need a file for this job. Create file named "controller.php" within components/com_hello/.

Hope this post help you.



Series this article:
Joomla MVC: Introduction using Model View Controller
Joomla MVC: How to Implement MVC Pattern in Joomla?
Joomla MVC: How MVC Pattern Works in Joomla?
Joomla MVC: Updating hello.php As Component
Joomla MVC: Creating Controller Section
Joomla MVC: Creating Model that Show All Data
Joomla MVC: Creating View That Show All Data
Joomla MVC: Creating Default Template for View All
Joomla MVC: Creating Model that Show Individual Data
Joomla MVC: Creating View That Show a Data
Joomla MVC: Creating Default Template for View

| Give Your Opinion | Recommend
Share and Bookmark to: These icons link to social bookmarking sites where readers can share and discover new web pages.
digg del.icio.us technorati Ma.gnolia BlinkList

Recommended articles by other readers:
Web Services: How PHP Kiss VB.NET? (Part 1)
Chart: How to Build Cool Animation Real Time Chart
Joomla: Fast Road to Understand Component Programming
Email: Send Attachement Mail
mod_rewrite - Part 1: create your "fantasy" URL

What do You Think?
Your Name *:
Email *:
(Will not be published)
Website/URL:
Your Comment *:
* Required


615
posting