halli hallo,
ich habe folgendes problem. Ich habe nach einer bestimmten Anleitung ein search bot für sobi2 gebaut und irgend wie gibt er mir jetzt immer ein ergeniss aus egal was ich rein schreibe =( könnt Ihr mir evtl. helfen??
Hier mal der code
PHP-Code:
<?php
defined( '_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' );
$_MAMBOTS->registerFunction( 'onSearch', 'sobi2searchbot' );
function sobi2searchbot( $text, $phrase='', $ordering='' ) {
global $database, $my;
$text = trim( $text );
if ($text == '') {
return array();
}
$wheres = array();
switch ($phrase) {
case 'exact':
$wheres2 = array();
$wheres2[] = "LOWER(b.title) LIKE '%$text%'";
$where = '(' . implode( ') OR (', $wheres2 ) . ')';
break;
case 'all':
case 'any':
default:
$words = explode( ' ', $text );
$wheres = array();
foreach ($words as $word) {
$wheres2 = array();
$wheres2[] = "LOWER(b.title) LIKE '%$word%'";
//$wheres[] = implode( ' OR ', $wheres2 );
$wheres[] = '(' . implode( ') OR (', $wheres2 ) . ')';
}
if(count($words == 1)) {
$where = '(' . implode( ') OR (', $wheres2 ) . ')';
} else {
$where = '(' . implode( ($phrase == 'all' ? ') AND (' : ') OR ('), $wheres ) . ')';
}
break;
}
switch ( $ordering ) {
case 'alpha':
$order = 'b.title ASC';
break;
default:
$order = 'g.itemid DESC';
}
$query = "SELECT b.itemid AS title,"
. "\n '2' AS browsernav,"
. "\n CONCAT ( 'index.php?option=com_sobi2&Itemid=',b.itemid ) AS href"
. "\n FROM #__sobi2_item AS b,"
. "\n FROM #__sobi2_item AS g,"
. "\n WHERE g.itemid = b.title "
. "\n ORDER BY $order"
;
//echo str_replace("#__", "jos_", $query);
$database->setQuery( $query );
$rows = $database->loadObjectList();
return $rows;
}
?>
Lesezeichen