Mobile-Menu iFuturz Infoweb Inc. Contact Portfolio

02

Jul

MVC Framework

MVC Framework

Posted On : July 2, 2013

| No Comment

What Is MVC ?

MVC is an architectural pattern used in software engineering. In complex computer applications that present lots of data to the user, one often wishes to separate data (model) and user interface (view) concerns, so that changes to the user interface do not impact the data handling, and that the data can be reorganized without changing the user interface. The model-view-controller solves this problem by decoupling data access and business logic from data presentation and user interaction, by introducing an intermediate component: the controller.

  • The Model encapsulates your application data, application flow, and business logic.
  • The View extracts data from the Model and format it for presentation
  • The Controller direct application flow and receive input and translates it for the Model and View.

How to Implement MVC Pattern in Joomla?

First, we glance over following structure file:

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.

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:

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:
1 view
2 + all
3 – view.html.php
4 + tmpl
5 – default.php
6 + hello
7 – view.html.php
8 + tmpl
9 – default.php

Controller

We just need a file for this job. Create file named “controller.php” within components/com_hello/. ¬†which represents the classes connecting the model and the view, and is used to communicate between classes in the model and view. . It provides the user with input by arranging for relevant views to present themselves in appropriate places on the screen. It provides means for user output by presenting the user with menus or other means of giving commands and data. The controller ¬†receives such user output, translates it into the appropriate messages and pass these messages on to one or more of the views.

 

  • Tags:

Comment