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

Searching


Although pagination will help our restaurant critics to navigate through the records in consistent chunks, sometimes they will have a specific review in mind or will want to narrow down the display to a certain set of reviews. Adding search capabilities to our component will help the reviewers find specific reviews quickly. The changes that were made to the all model for pagination will make adding the search feature a little easier.

Adjusting the model

The model will now need to keep track of the search term for multiple calls. Also, as the query will no longer be a static string, this should be cached as well. Add the following private variables to the all model:

var $_total = null;
var $_search = null;
var $_query = null;

Next, the model will need a function that prepares the search term and returns it. This function needs to do three things get the search term from the session (rather than the request), set it to lowercase, and store it in the $_search member variable. Add...