Доброго времени суток! В админке в модуле YJ K2 Filter появилось сообщение об ошибке: Код: Fatal error: Call to a member function setQuery() on a non-object in /www/modules/mod_yjk2filter/helpers/actions/get_param_fields_group.php on line 57 Ниже приведен кусок кода, на который жалуется Joomla (строка о которой говорится в ошибке - PHP: //get the module params for extra fields connection $sql = "SELECT params FROM #__modules WHERE module = 'mod_yjk2filter'"; $db->setQuery($sql); $mod_params = $db->loadResult(); Конфигурация: Joomla! 2.5.7 + K2 v2.6.5 + K2Store 3.0.3 + YJ K2 Filter Помогите решить проблему!
напиши PHP: global $db; после PHP: function имя_функции () { где function - это функция в которой находится твой код.
PHP: <?php// Set flag that this is a parent fileif(!defined('_JEXEC')) define( '_JEXEC', 1 ); define( 'DS', DIRECTORY_SEPARATOR );$path_base = str_replace("modules/mod_yjk2filter/helpers/actions","",dirname(__FILE__));$path_base = str_replace("modules\mod_yjk2filter\helpers\actions","",$path_base); define('JPATH_BASE', $path_base ); require_once ( JPATH_BASE .'/includes/defines.php' );require_once ( JPATH_BASE .'/includes/framework.php' ); require_once ( JPATH_BASE .'/includes/application.php' );require_once ( JPATH_ADMINISTRATOR.DS."components".DS."com_k2".DS.'lib'.DS.'JSON.php'); $mainframe = &JFactory::getApplication('site');$db = &JFactory::getDBO(); JRequest::clean(); //load the language files also$lang = JFactory::getLanguage();$lang->load("mod_yjk2filter", JPATH_SITE, null, false, false); $k2_check = JFolder::exists(JPATH_ROOT.DS."components".DS."com_k2".DS);if($k2_check): $params = &JComponentHelper::getParams('com_k2'); $document = &JFactory::getDocument(); JHtml::_('behavior.framework', true); //get the group id $group_id = JRequest::getInt('group_id'); //display extra fields for the selected group id if($group_id > 0): //get the module params for extra fields connection $sql = "SELECT params FROM #__modules WHERE module = 'mod_yjk2filter'"; $db->setQuery($sql); $mod_params = $db->loadResult(); // Instantiate the params. $params = new JRegistry; $params->loadString($mod_params); $db = &JFactory::getDBO(); $query = 'SELECT m.* FROM #__k2_extra_fields as m WHERE m.published = 1 AND m.group = '.$group_id.' AND (m.type = "select" OR m.type = "multipleSelect" OR m.type = "textfield" OR m.type = "radio") GROUP BY [URL='http://m.name/']m.name[/URL] ORDER BY m.group, m.ordering ASC'; $db->setQuery( $query ); $list = $db->loadObjectList(); // Make sure there aren't any errors if ($db->getErrorNum()) { echo $db->getErrorMsg(); exit; } if(is_array($list) && !empty($list)): foreach ( $list as $item ) { $item->name = JString::str_ireplace(' ', '- ', $item->name); $mitems[] = JHTML::_('select.option', $item->id, ' '.$item->name ); } $fieldName = 'jform[params][yjk2filter_extrafields_id][]'; $output= JHTML::_('select.genericlist', $mitems, $fieldName, ' multiple="multiple"', 'value', 'text', $params->get('yjk2filter_extrafields_id') ); else: $output= ' <select id="jformparamsyjk2filter_extrafields_id" class="inputbox" size="10" multiple="multiple" style="width:90%;" name="params[yjk2filter_extrafields_id][]" disabled="disabled"> <option value="" disabled="disabled">'.JText::_('MOD_YJK2FILTER_NO_EXTRAFIELDS_FOUND').'</option> </select><br /> '; endif; else: $fieldName = 'jform[params][yjk2filter_extrafields_id][]'; //empty group id, do not display any extra fields $output= JHTML::_('select.genericlist', array() , $fieldName, 'multiple="multiple"', 'value', 'text', '' ); endif; else: $output= ' <select id="jformparamsyjk2filter_extrafields_id" class="inputbox" size="10" multiple="multiple" style="width:90%;" name="params[yjk2filter_extrafields_id][]" disabled="disabled"> <option value="" disabled="disabled">K2 is not installed!</option> </select><br /> ';endif;echo $output; а куда именно, если не сложно уточнить))) --- добавлено: 21 мар 2013 в 17:03 --- в эту функцию или в какую?
Та же проблема, причем при выборе любого из параметров фильтра, страница обновляется и снова отображается главная. Ощущение, что проблема с настройкой фильтра в части БД. Комрады, подскажите как исправить!
не уверен, но попробуйте так: PHP: <?php// Set flag that this is a parent fileif(!defined('_JEXEC')) define( '_JEXEC', 1 ); define( 'DS', DIRECTORY_SEPARATOR );$path_base = str_replace("modules/mod_yjk2filter/helpers/actions","",dirname(__FILE__));$path_base = str_replace("modules\mod_yjk2filter\helpers\actions","",$path_base); define('JPATH_BASE', $path_base ); require_once ( JPATH_BASE .'/includes/defines.php' );require_once ( JPATH_BASE .'/includes/framework.php' ); require_once ( JPATH_BASE .'/includes/application.php' );require_once ( JPATH_ADMINISTRATOR.DS."components".DS."com_k2".DS.'lib'.DS.'JSON.php'); $mainframe = &JFactory::getApplication('site');$db = &JFactory::getDBO();global $database; JRequest::clean(); //load the language files also$lang = JFactory::getLanguage();$lang->load("mod_yjk2filter", JPATH_SITE, null, false, false); $k2_check = JFolder::exists(JPATH_ROOT.DS."components".DS."com_k2".DS);if($k2_check): $params = &JComponentHelper::getParams('com_k2'); $document = &JFactory::getDocument(); JHtml::_('behavior.framework', true); //get the group id $group_id = JRequest::getInt('group_id'); //display extra fields for the selected group id if($group_id > 0): //get the module params for extra fields connection $sql = "SELECT params FROM #__modules WHERE module = 'mod_yjk2filter'"; $database->setQuery($sql); $mod_params = $database->loadResult(); // Instantiate the params. $params = new JRegistry; $params->loadString($mod_params); $db = &JFactory::getDBO(); $query = 'SELECT m.* FROM #__k2_extra_fields as m WHERE m.published = 1 AND m.group = '.$group_id.' AND (m.type = "select" OR m.type = "multipleSelect" OR m.type = "textfield" OR m.type = "radio") GROUP BY m.name ORDER BY m.group, m.ordering ASC'; $db->setQuery( $query ); $list = $db->loadObjectList(); // Make sure there aren't any errors if ($db->getErrorNum()) { echo $db->getErrorMsg(); exit; } if(is_array($list) && !empty($list)): foreach ( $list as $item ) { $item->name = JString::str_ireplace(' ', '- ', $item->name); $mitems[] = JHTML::_('select.option', $item->id, ' '.$item->name ); } $fieldName = 'jform[params][yjk2filter_extrafields_id][]'; $output= JHTML::_('select.genericlist', $mitems, $fieldName, ' multiple="multiple"', 'value', 'text', $params->get('yjk2filter_extrafields_id') ); else: $output= ' <select id="jformparamsyjk2filter_extrafields_id" class="inputbox" size="10" multiple="multiple" style="width:90%;" name="params[yjk2filter_extrafields_id][]" disabled="disabled"> <option value="" disabled="disabled">'.JText::_('MOD_YJK2FILTER_NO_EXTRAFIELDS_FOUND').'</option> </select><br /> '; endif; else: $fieldName = 'jform[params][yjk2filter_extrafields_id][]'; //empty group id, do not display any extra fields $output= JHTML::_('select.genericlist', array() , $fieldName, 'multiple="multiple"', 'value', 'text', '' ); endif; else: $output= ' <select id="jformparamsyjk2filter_extrafields_id" class="inputbox" size="10" multiple="multiple" style="width:90%;" name="params[yjk2filter_extrafields_id][]" disabled="disabled"> <option value="" disabled="disabled">K2 is not installed!</option> </select><br /> ';endif;echo $output; Не факт что поможет. Так же еще может возникать из-за несовпадения версий джумлы и модулей.