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 the reviews


Some of our visitors have complained that they cannot find restaurant reviews through the search form. We can fix this by writing a search plug-in to scan the reviews along with the results for content. Create a file name/plugins/search/reviews.php, and add the following code to it:

<?php
defined( '_JEXEC' ) or die( 'Restricted access' );
jimport( 'joomla.plugin.plugin' );
class plgSearchReviews extends JPlugin
{

In contrast to our content plug-in, for the search plug-in we are extending the JPlugin class instead of calling the registerEvent() member function of the mainframe object. This is a newer method of constructing plug-ins, that is becoming the preferred method.

To start using this style, jimport('joomla.plugin.plugin') is called to load the plug-in code into memory. After this, a class is defined that extends JPlugin. The name format for this class starts with plg, continues with a capitalized form of the plug-in group name (in this case Search), and ends...