000-CMS
avatar mikajaxxx
mikajaxxx
28 Nov 2019

I am working on a module to retrieve module parameters by ajax in helper.php :
$app = JFactory::getApplication();
$module = JModuleHelper::getModule('mod_mymodule');
$params = new JRegistry($module->params);
It works on single module on the page but if i have instance of module this method doesn't work and returns the parameter of other module as result!
so i tried using JModuleHelper::getModuleById($id);
and also
ModuleHelper::getModule('mod_mymodule','m1');
to solve the problem and point to specific instance of module. but none of them works on ajax function so i created a simulation to check the situation in a ajax function and normal function:

Steps to reproduce the issue

Creating module of type 'mod_mymodule' with name "m1"
creating 2 function in helper.php of module
function 1: render(); // function for testing
function 2: getbyajax(); // function to deal with ajax call.

i put following syntax in both functions:
$module = JModuleHelper::getModule('mod_mymodule','m1');
echo $module ->id;

Expected result

both function must return the id of module!

Actual result

function 1 works ;
function 2 doesn't works and render 0 as result;

System information (as much as possible)

Joomla 3.9.11

Additional comments

i also tested another function in both function ($id is the id of the module ).
$module = JModuleHelper::getModuleById($id);
echo $module->id;
the same result again! and first function is working but the ajax function doesn't work and returns 0
I think the joomla ajax can't detect correct instance of module.
Best

avatar mikajaxxx mikajaxxx - open - 28 Nov 2019
avatar mbabker mbabker - close - 29 Nov 2019
avatar mbabker
mbabker - comment - 29 Nov 2019

Hi, this repository is for reporting bugs on the issue tracker itself. To report a bug on Joomla, please use https://github.com/joomla/joomla-cms/issues.

avatar mbabker mbabker - change - 29 Nov 2019
Status New Closed
Closed_Date 0000-00-00 00:00:00 2019-11-29 02:47:45
Closed_By mbabker
avatar mbabker mbabker - change - 29 Nov 2019
Labels Added: 000-CMS
avatar mbabker mbabker - labeled - 29 Nov 2019

Add a Comment

Login with GitHub to post a comment