Hallo zusammen,
ich schreibe gearde mein erstes Plug in als Suchfunktion nur leider klappt es nicht so wie ich es will. Kann mir jemand vielleicht weiter helfen. Ich bekomme immer wieder folgende Meldung.
Warning: Invalid argument supplied for foreach() in /xxx/xx/htdocs/pizza/plugins/search/pizza.php on line 87
Anbei der Code:Danke für eure HilfeCode:<?php // no direct access defined( '_JEXEC' ) or die( 'Restricted access' ); $mainframe->registerEvent( 'onSearch', 'plgSearchPizza' ); $mainframe->registerEvent( 'onSearchAreas', 'plgSearchPizzaAreas' ); /** * @return array An array of search areas */ function &plgSearchPizzaAreas() { static $areas = array( 'pizza' => 'Pizza' ); return $areas; } function plgSearchPizza( $text, $phrase='', $ordering='', $areas=null ) { $db =& JFactory::getDBO(); $user =& JFactory::getUser(); if (is_array( $areas )) { if (!array_intersect( $areas, array_keys( plgSearchPizzaAreas() ) )) { return array(); } } // load plugin params info $plugin =& JPluginHelper::getPlugin('search', 'pizza'); $pluginParams = new JParameter( $plugin->params ); $limit = $pluginParams->def( 'search_limit', 50 ); $text = trim( $text ); if ($text == '') { return array(); } $section = JText::_( 'Pizza' ); $wheres = array(); switch ($phrase) { case 'exact': $text = $db->getEscaped($text); $wheres2 = array(); $wheres2[] = "LOWER(a.text) LIKE '%$text%'"; $wheres2[] = "LOWER(a.pizza) LIKE '%$text%'"; $where = '(' . implode( ') OR (', $wheres2 ) . ')'; break; case 'all': case 'any': default: $words = explode( ' ', $text ); $wheres = array(); foreach ($words as $word) { $word = $db->getEscaped($word); $wheres2 = array(); $wheres2[] = "LOWER(a.text) LIKE '%$word%'"; $wheres2[] = "LOWER(a.pizza) LIKE '%$word%'"; $wheres[] = implode( ' OR ', $wheres2 ); } $where = '(' . implode( ($phrase == 'all' ? ') AND (' : ') OR ('), $wheres ) . ')'; break; } switch ( $ordering ) { default: $order = 'a.text ASC'; break; } $query = "SELECT * FROM #__pizza AS a" . "\n WHERE ( $where )" . "\n AND published = '1'" . "\n ORDER BY $order"; ; //echo $query; die(); $db->setQuery( $query, 0, $limit ); $rows = $db->loadObjectList(); foreach($rows as $key => $row) { $rows[$key]->href = 'index.php?option=com_pizza&view=pizza'; } return $rows; } ?>


LinkBack URL
About LinkBacks
Zitieren

Lesezeichen