How to have DirectPHP commands processed in Joomla search (for Joomla 1.5.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.5.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.5.x only. For Joomla 1.0.x, please refer to How to have DirectPHP commands processed in Joomla search (for Joomla 1.0.x)?. SolutionAll you need is to add 7 lines to have the DirectPHP commands processed by Joomla search. For Joomla 1.5.3 and earlier
function getData()
{
// Lets load the content if it doesn't already exist
if (empty($this->_data))
{
$areas = $this->getAreas();
JPluginHelper::importPlugin( 'search');
$dispatcher =& JDispatcher::getInstance();
$results = $dispatcher->trigger( 'onSearch', array(
$this->getState('keyword'),
$this->getState('match'),
$this->getState('ordering'),
$areas['active']) );
$rows = array();
for ($i = 0, $n = count( $results); $i < $n; $i++) {
$rows = array_merge( (array)$rows, (array)$results[$i] );
}
$dispatcher =& JDispatcher::getInstance();
JPluginHelper::importPlugin('content');
global $mainframe;
$params2 =& $mainframe->getParams('com_content');
for ($i=0; $i<count($rows); ++$i) {
$results = $dispatcher->trigger('onPrepareContent',
array (&$rows[$i], &$params2, 0));
}
$this->_total = count($rows);
if($this->getState('limit') > 0) {
$this->_data = array_splice($rows,
$this->getState('limitstart'), $this->getState('limit'));
} else {
$this->_data = $rows;
}
}
return $this->_data;
}
For Joomla 1.5.4 and after
function getData()
{
// Lets load the content if it doesn't already exist
if (empty($this->_data))
{
$areas = $this->getAreas();
JPluginHelper::importPlugin( 'search');
$dispatcher =& JDispatcher::getInstance();
$results = $dispatcher->trigger( 'onSearch', array(
$this->getState('keyword'),
$this->getState('match'),
$this->getState('ordering'),
$areas['active']) );
$rows = array();
for ($i = 0, $n = count( $results); $i < $n; $i++) {
// Lets remove HTML and check again
foreach ($results[$i] as $_result) {
if ( strpos(strtolower(strip_tags($_result->text)),
strtolower($this->getState('keyword'))) === false) {
} else {
$rows[] = $_result;
}
}
}
$dispatcher =& JDispatcher::getInstance();
JPluginHelper::importPlugin('content');
global $mainframe;
$params2 =& $mainframe->getParams('com_content');
for ($i=0; $i<count($rows); ++$i) {
$results = $dispatcher->trigger('onPrepareContent',
array (&$rows[$i], &$params2, 0));
}
$this->_total = count($rows);
if($this->getState('limit') > 0) {
$this->_data = array_splice($rows,
$this->getState('limitstart'), $this->getState('limit'));
} else {
$this->_data = $rows;
}
}
return $this->_data;
}
That's it! Your DirectPHP commands should now be processed even within Joomla search! User reviews There are no user reviews yet. Note: You have to be a registered member to leave a comment. Free registration here. |
||
| < Prev | Next > |
|---|
Joomla 1.0 Articles
- How to create a module with DirectPHP plugin?
- How to include modules in Content item?
- How to include modules in Section/Content Description
- How to include PHP commands in Section/Content Description
- How to make plugins process Section/Category descriptions
- Include Code Listing plugin - More Tips and Techniques
- How to have DirectPHP plugin process RSS feed?
- How to have the plugins processed when genrating PDF documents of content items?
- How to have DirectPHP commands processed in Joomla search?
Joomla 1.5 Articles
- How to create a module with DirectPHP plugin?
- How to include modules in Content item?
- How to include modules in Section/Content Description
- How to include PHP commands in Section/Content Description
- How to make plugins process Section/Category descriptions
- Include Code Listing plugin - More Tips and Techniques
- How to have DirectPHP plugin process RSS feed?
- How to have the plugins processed when genrating PDF documents of content items?
- How to have DirectPHP commands processed in Joomla search?
Joomla Plugins
Joomla Components
Joomla Gadgets
- Google Image Search
- Google News Search
- Wikipedia Search
- Google Book Search
- Google Video Search
- Google Currency Converter - AJAX version
- Yahoo Currency Converter - AJAX version
- Yahoo Stock Quote (AJAX module version)
- Yahoo Stock Quote (AJAX component/ module version)
- googleSearch_cse component
- googleSearch_cse module
- googleMaps plugin






