将模块添加到Joomla中的子页面



我有一个模块,我从管理面板添加到某个子页面。之后,一些子页面正确显示此模块的内容,但单击它后的一些子页面打开空白的白色页面,里面没有内容。我不知道是什么导致了这个问题。为什么带有此模块的某些子页面可以正常工作,而某些子页面显示空白页? 这是我在页面上看到的:

致命错误:无法在第 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;
}

}

根据我所能收集的信息,您已经创建了一个模块并将其分配给特定页面。你还没有提到模块的内容是什么(自定义html等(。

您是否将模块分配到"模块分配"选项卡中的正确页面?看看这个问题和答案,因为它解释了如何做到这一点。

如果您看到一个白页,我建议您在Joomla中启用错误报告。这应该为您提供有关错误的其他有用信息。

如果您有指向您的网站的链接,这将有所帮助,以及您正在使用的Joomla版本。

最新更新