0

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

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

}

4

1 回答 1

1

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

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

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

如果您有一个对您的网站有帮助的链接,以及您正在使用的 Joomla 版本。

于 2017-07-21T11:24:08.190 回答