two different joomla Modules that display the same information

For Joomla! 3.x Coding related discussions, you could also use: http://groups.google.com/group/joomla-dev-general

Moderators: ooffick, General Support Moderators

Forum rules
Locked
lminfo
Joomla! Fledgling
Joomla! Fledgling
Posts: 2
Joined: Mon Jan 02, 2017 7:39 pm

two different joomla Modules that display the same information

Post by lminfo » Thu Mar 01, 2018 9:08 pm

I have a module that displays info from a Joomla table. The module has form fields to configure it. Here is the problem: When I create an instance of this module with the appropriate parameters and display that module in one position, everything works. Now, I unpublish the module. I create a second instance of the module (different name) with other parameters and I display it without problem in a second position. Now when I want to display the two modules in the same page in the two different positions, they then display the data of the first module. The data of the second one are not taken into account.

Here is the module code:

Code: Select all

<?php
// Pas d'acces direct
defined('_JEXEC') or die;
// Inclure la fonction de recuperation des donnees
require_once dirname(__FILE__).'/helper.php';

// Recuperer les choix a partir du fichier XML
$module = JModuleHelper::getModule('mod_evenementdmmc');
$params =  new JRegistry($module->params);
$position = $params->get('position', 'g'); // Position du module
$special = $params->get('special', '50');  // Cas speciaux a traiter
$event = $params->get('choixEvent', '0');  // Choix de l'evenement a traiter

// Recuperer les donnees pour les evenements
$lstInfos = ModEvenementdmmcHelper::getInfos($event);

require JModuleHelper::getLayoutPath('mod_evenementdmmc');
The Helper code:

Code: Select all

<?php
/**
 * Classe Helper class pour le module Evenements du DMMC
 **/
class ModEvenementdmmcHelper
{
    /**
     * Recherche les donnees associees aux choix de l'utilisateur
     *
     * @params - Choix effectues
     *
     * @access public
     */    
    public static function getInfos($param) { 
        // Acces a la BD et recuperation des donnees
        $db = JFactory::getDbo();
        $query = $db->getQuery(true);

        $query 
            ->select(array('t.*', $db->quoteName('c1.nomclub', 'nomclub1'), $db->quoteName('c2.nomclub', 'nomclub2')))
            ->from($db->quoteName('#__trntournois', 't'))
            ->join('INNER', $db->quoteName('#__trnclubs', 'c1').' ON ('.$db->quoteName('c1.idclub').' = '.$db->quoteName('t.club1').')')
            ->join('INNER', $db->quoteName('#__trnclubs', 'c2').' ON ('.$db->quoteName('c2.idclub').' = '.$db->quoteName('t.club2').')')
            ->where($db->quoteName('t.idtrn')." = ".$db->quote($param));
        $db->setQuery($query);

        $results = $db->loadObject();

        return $results;
    }
}
Last edited by imanickam on Fri Mar 02, 2018 4:51 am, edited 1 time in total.
Reason: Moved the topic from the forum General Questions/New to Joomla! 3.x to the forum Joomla! 3.x Coding

lminfo
Joomla! Fledgling
Joomla! Fledgling
Posts: 2
Joined: Mon Jan 02, 2017 7:39 pm

Re: two different joomla Modules that display the same information

Post by lminfo » Sat Mar 03, 2018 8:19 pm

After several readings on the Joomla versions, I found that the management of the module parameters in the Joomla 3.8 version was extremely simplified. The module, when it is created, provides two useful variables. The first is $module which returns the general parameters of the module:

Code: Select all

$module ( 
[id] => 153 
[title] => Event futur 
[module] => mod_evenementdmmc 
[position] => bottom-a 
[content] => .....
[showtitle] => 0 
[control] => .....
[params] => .....
...
)
The second parameter is called $params and it returns the values entered by the user in the module form (XML file). Here is an example for my case:

Code: Select all

$params (
[position] => 'd' 
[special] =>  '0'
[choixEvent] => '2'
...
)
As a result, the module code has been simplified. Just use the $params variable to retrieve the requested results for this module. Here is the code:

Code: Select all

<?php
// Pas d'acces direct
defined('_JEXEC') or die;
// Inclure la fonction de recuperation des donnees
require_once dirname(__FILE__).'/helper.php';

// Recuperer les parametres choisis par l'utilisateur
$position = $params->get('position', 'g'); // Position du module
$special = $params->get('special', '50');  // Cas speciaux a traiter
$event = $params->get('choixEvent', '0');  // Choix de l'evenement a traiter

// Recuperer les donnees pour les evenements
$lstInfos = ModEvenementdmmcHelper::getInfos($event);

require JModuleHelper::getLayoutPath('mod_evenementdmmc');


Locked

Return to “Joomla! 3.x Coding”