0

I have a module which I add from admin panel to some subpage. After that some subpages show properly content with this module but some subpages after click on it open blank, white page with no content inside. I don't know what caused that problem. Why some subpages with this module work properly and some show blank page? This is what I see on page:

Fatal error: Cannot redeclare class ModProductsMenuHelper in /opt2/data-dev/modules/mod_products_menu/helper.php on line 15

Thank you for help! This is my code

   <?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;
}

}

jonboy
  • 2,729
  • 6
  • 37
  • 77
j.doe
  • 47
  • 7

1 Answers1

1

From what I can gather you have created a module and assigned it to specific pages. You haven't mentioned what the contents of the module are (custom html etc).

Have you assigned the module to the correct pages in the 'module assignment' tab? Have a look at this question and answer as it explains how to do that.

If you are seeing a white page, i'd suggest enabling error reporting in Joomla. This should provide you with additional useful information about the error.

If you have a link to your website that would be helpful, and the version of Joomla you are using.

TheOrdinaryGeek
  • 2,273
  • 5
  • 21
  • 47
  • The content of module is custom html. This module is on homepage and it is lists of products. Now I'd like to add this module to other subpages. So if this list of products works properly on main page on other page should too. I know how to add modules but I don't know why on some subpages after turn on this module appears white page. My version of Joomla is Joomla! 3.4.3 . – j.doe Jul 21 '17 at 11:32
  • Have you enabled error reporting like I suggested? This should definitely help troubleshoot the issue. Add the results to your original question. – TheOrdinaryGeek Jul 21 '17 at 11:42
  • Line 15 starts after class ModProductsMenuHelper – j.doe Jul 21 '17 at 13:41
  • Can someone suggest any solution? – j.doe Jul 24 '17 at 11:28