Friday 5 April 2013

Introduction to Model-View-Controller in Joomla

Model-View-Controller (herein referred to as MVC) is a software design pattern that can be used to organize code in such a way that the business logic and data presentation are separate.MVC was originally developed to map the traditional input, processing, output roles into a logical GUI architecture.

Model

 In our case, the model will contain methods to add, remove and update information about the greetings in the database. By the query you can fetch all data, save,delete, update the data. the model is the only element that needs to be changed, not the view or the controller.

View

 The view is the part of the component that is used to render the data from the model in a manner that is suitable for interaction. For a web-based application, the view would generally be an HTML page that is returned to the user. The view pulls data from the model (which is passed to it from the controller) and feeds the data into a template which is populated and presented to the user. The view does not cause the data to be modified in any way, it only displays data retrieved from the model.

In other ur Template of any page(means Html) is nothing but view, on that page you can fetch all data from database by model(bypass from controller because controller control all acction).

Controller

 The controller is responsible for responding to user actions. In the case of a web application, a user action is (generally) a page request. The controller will determine what request is being made by the user and respond appropriately by triggering the model to manipulate the data appropriately and passing the model into the view. The controller does not display the data in the model, it only triggers methods

MVC connection

he simplified picture on the right depicts the basic components being used within Joomla. Besides the Model, the View and the Controller.

 

No comments:

Post a Comment