【问题标题】:Add module to subpage in Joomla在 Joomla 中将模块添加到子页面
【发布时间】:2017-07-21 10:58:32
【问题描述】:

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

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

}

【问题讨论】:

    标签: joomla3.4


    【解决方案1】:

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

    您是否已将模块分配到“模块分配”选项卡中的正确页面?看看this question and answer,它解释了如何做到这一点。

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

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

    【讨论】:

    • 模块内容为自定义html。该模块在主页上,它是产品列表。现在我想将此模块添加到其他子页面。因此,如果此产品列表在其他页面的主页上正常工作,也应该如此。我知道如何添加模块,但我不知道为什么打开此模块后在某些子页面上出现白页。我的 Joomla 版本是 Joomla! 3.4.3 .
    • 您是否按照我的建议启用了错误报告?这绝对应该有助于解决问题。将结果添加到您的原始问题中。
    • 第 15 行在 ModProductsMenuHelper 类之后开始
    • 有人可以提出任何解决方案吗?
    猜你喜欢
    • 2013-01-21
    • 2011-09-05
    • 2011-02-04
    • 2016-10-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多