Joomla 2.5 search customization

To customize the joomla search we need to first edit the form layout and add your expected field for user input to search .

the file default_form.php which we need to edit will be in  components\com_search\views\search\tmpl\ Now your form is ready .

Example :  I added two field for articles which will search articles between to publish date

<?php echo JHTML::_(‘calendar’,$_REQUEST['start'],’start’,’start’,’%Y-%m-%d’,’size=”10″,title =”start”‘);

echo JHTML::_(‘calendar’,$_REQUEST['end'],’end’,’end’,’%Y-%m-%d’,’size=”10″,title =”End”‘);?>

The joomla search is working with plugin the result will be fetch from the joomla DB via plugin whichever you enabled in your site .

By default there will be 5 plugin of type search which are going to render your search result :

Search – Categories
Search – Contacts
Search – Content
Search – Newsfeeds
Search – Weblinks

each of the plugin will have the Logic (Mysql Query) to render the result .

So you need to see the proper logic and add your logic in existing Query .

Folder for search plugin :

plugins\search

For my requirement i edited content plugin :

plugins\search\content

Example : Line 158

//akash
if(isset($_REQUEST['start']) && isset($_REQUEST['start'])){
$newwhere=”AND (a.publish_up BETWEEN ‘”.$_REQUEST['start'].”‘ AND ‘”.$_REQUEST['end'].”‘ )”;
}else{$newwhere=”;}
//akash
$query->where(‘(‘. $where .’) ‘ .$newwhere .’ AND a.state=1 AND c.published = 1 AND a.access IN (‘.$groups.’) ‘
.’AND c.access IN (‘.$groups.’) ‘
.’AND (a.publish_up = ‘.$db->Quote($nullDate).’ OR a.publish_up <= ‘.$db->Quote($now).’) ‘
.’AND (a.publish_down = ‘.$db->Quote($nullDate).’ OR a.publish_down >= ‘.$db->Quote($now).’)’  );

Smiler way you can built your logic . ;)

Show Buttons
Hide Buttons