How to have DirectPHP commands processed in Joomla search (for Joomla 1.0.x)?
Written by kksou   
Monday, 04 August 2008

Suppose you have installed the DirectPHP plguin, which allows you to embed PHP commands right inside your Joomla content item..

In standard Joomla 1.0.x search, the DirectPHP commands will be visible in the search result. This is both undesirable and confusing to the users.

This article shows you how to have the DirectPHP commands processed in Joomla search.

Note: the steps below works for Joomla 1.0.x only. For Joomla 1.5.x, please refer to How to have DirectPHP commands processed in Joomla search (for Joomla 1.5.x)?.


Solution

All you need is to add 4 lines to have the DirectPHP commands processed by Joomla search.

  1. Go to the folder <Joomla root folder>/components/com_search, you will see a file called search.php.
  2. Open this file search.php in your favorite editor.
  3. Go to around Line 181. Within the function viewSearch(), add the four lines highlighted in yellow as shown follow:
  4. $totalRows = count( $rows );
    
    for ($i=0; $i < $totalRows; $i++) {
    	$text = &$rows[$i]->text;
    
    	global $_MAMBOTS;
    	$params2 = new stdClass();
    	$_MAMBOTS->loadBotGroup( 'content' );
    	$results = $_MAMBOTS->trigger( 'onPrepareContent', 
    	    array( 1, &$rows[$i], &$params2) );
    
    	if ($searchphrase == 'exact') {
    		$searchwords 	= array($searchword);
    		$needle 		= $searchword;
    	} else {
    		$searchwords 	= explode(' ', $searchword);
    		$needle 		= $searchwords[0];
    	}
    
  5. Save and close this file.

That's it! Your DirectPHP commands should now be processed even within Joomla search!


 

Add comment


Security code
Refresh

< Prev   Next >

Blog - Forum - Privacy Policy - Contact Us
Copyright © 2006-2012. kksou.com. All Rights Reserved