Searching com datafeeds using the component

The search plugin included in the component extends the search component of the joomla core software. This search funcationilty allows to search in all types of content items ( articles, datafeeds, forum etc etc).

For sites using only the datafeeds as content it might be an option to search and display directly in the datafeeds component instead.

Searching is possible be adding a ?q= to the page url, this works for rss-feeds as well.

To add a searchbox to search in the component only put the following code into modules/mod_datamenu/tmpl/searchbox_custom.php and add a module using this template.

From version 1260 a module layout is included (search17_custom). This file should work for 1.5 as wel. Avaiable in the svn repositoy or use the code below as example.

The component will not search in the description/title of the items, only the Select0..9 fields. This can be extended to title and description, information is available for licensed users.

<?php // no direct access
#
# Copyright brambring.nl
# http://www.affiliatefeeds.nl
Dit e-mailadres is beschermd tegen spambots. U heeft Javascript nodig om het te kunnen zien.
#
defined'_JEXEC' ) or die( 'Restricted access' );
function 
Datasearchbox_customMenu(&$dataitems,&$params)  {
?>
  <div id="search">
  <form action="index.php"  method="post" name="searchprod" 
         id="prodsearch">
  <table cellpadding="0" cellspacing="0" border="0"><tr>
  <?php
    $db
=& JFactory::getDBO();
    
$query "SELECT count(*) as count FROM #__dataitems";
    
$db->setQuery($query);
    
$text=JText::_('Search in').' '$db->loadResult() .' '.JText::_(
           'Products'
);
    echo  
'<td><input name="q" id="searchbox"  value="'.$text.
          
'"  onblur="if(this.value==\'\') this.value=\''.$text.
          
'\';" onfocus="if(this.value==\''.$text.'\') 
                 this.value=\'\';" /></td>'
;
    echo 
'</tr><tr>';
    echo  
'<td><input class="searchButton" type="submit" value="'.
           JText
::_('Search').'"/></td>';
  
?>
  </tr>
  </table>
  <input type="hidden" name="option" value="com_datafeeds" />
  <input type="hidden" name="task"   value="search" />
  <input type="hidden" name="Itemid" value="<?php echo $params->get(
         'id'
);?>" />
  </form>
  </div>
<?php }

/*
bare code ( to use in other layouts templates

  <form action="index.php"  method="post" name="searchprod" 
         id="prodsearch">
  <input class="searchButton" type="submit" value="<?php echo 
         JText::_('Search');?>"/>
  <input type="hidden" name="option" value="com_datafeeds" />
  <input type="hidden" name="task"   value="search" />
  <input type="hidden" name="Itemid" value="<?php echo $params->get( 
         'id');?>" />
  </form>
*/