我有一个模块,我从管理面板添加到某个子页面。之后,一些子页面会正确显示该模块的内容,但单击它后的一些子页面会打开空白的白色页面,里面没有内容。我不知道是什么导致了这个问题。为什么此模块的某些子页面可以正常工作而某些显示空白页面?这是我在页面上看到的:
致命错误:无法在第 15 行的 /opt2/data-dev/modules/mod_products_menu/helper.php 中重新声明类 ModProductsMenuHelper
谢谢你的帮助!这是我的代码
<?php
/**
* Slajder class for Hello World! module
*
* @package Joomla.Tutorials
* @subpackage Modules
* @link http://docs.joomla.org/J3.x:Creating_a_simple_module/Developing_a_Basic_Module
* @license GNU/GPL, see LICENSE.php
* mod_helloworld is free software. This version may have been modified pursuant
* to the GNU General Public License, and as distributed it includes or
* is derivative of works licensed under the GNU General Public License or
* other free or open source software licenses.
*/
class ModProductsMenuHelper
{
/**
* Retrieves the hello message
*
* @param array $params An object containing the module parameters
*
* @access public
*/
public function getProducts($params)
{
$lang = JFactory::getLanguage();
$langTag = $lang->getTag();
$app = JFactory::getApplication();
$isSMB = $app->get('isSMB');
$parentMenuId = $langTag == 'pl-PL' ? 107 : 103;
$results = $this->getChildren($parentMenuId, $langTag);
return $results;
}
private function getChildren($parentId, $langTag){
// Get a db connection.
$db = JFactory::getDbo();
// Create a new query object.
$query = $db->getQuery(true);
$query
->select(array('id', 'title', 'path', 'alias'))
->from($db->quoteName('#__menu'))
->where("(language = '*' OR language= ".$db->quote($langTag).") AND published = 1 AND parent_id=".$parentId)
->order($db->quoteName('lft') . ' ASC, '.$db->quoteName('id') . ' ASC');
// Reset the query using our newly populated query object.
$db->setQuery($query);
// Load the results as a list of stdClass objects (see later for more options on retrieving data).
$results = $db->loadObjectList();
foreach ($results as $key=>$val){
$results[$key]->children = $this->getChildren($val->id, $langTag);
}
return $results;
}
}