Book Image

Learning Joomla! 1.5 Extension Development

Book Image

Learning Joomla! 1.5 Extension Development

Overview of this book

Table of Contents (17 chapters)
Learning Joomla! 1.5 Extension Development
Credits
About the Author
About the Reviewer
Preface

Coding with MVC


Our first few encounters with the component have involved simple code where each line executes sequentially. Many standalone PHP scripts are also initially coded this way. Although this is good for learning how the code executes, it will soon become cluttered if we attempt to add multiple screens and data processing.

This is where the MVC design pattern helps keep things organized. Views will primarily be used to handle HTML output. Each view in our component will represent a different screen. In Joomla!, each view has its own folder containing individual files with HTML output. The folders also contain files that perform final data formatting.

Although it would be possible to add database queries directly into the view code, this would get messy before long. To avoid this, we will use models that pair with our views. The model will contain a function that queries the database, and then sorts the results into a suitable data structure. By default, each view will look for a...