2

I am trying to render a mod_login module - on the fly - from inside a system plugin. So far, there is no existing mod_login instance in the website nor the database. I am just trying to create a new module object through PHP.

For the same 3.9.19 website, the following code works on my MAMP localhost with php72, but it doesn't work on the online Litespeed server with php72.

$module = JModuleHelper::getModule('mod_login', '');
$moduleParams = new JRegistry($module->params);     
$moduleParams->set('style', "System-html5");
$module->showtitle = "1";
$module->title = $title;
$renderer = $doc->loadRenderer('module');
$modHtml = $renderer->render($module, array('params'=> $moduleParams));

On the online server, I have to create a login module and specifically select that one in order to render it, otherwise I am getting null params for the on-the-fly module and an empty string when it's rendered.

$module = JModuleHelper::getModule('mod_login', 'My Login');

So are there any special conditions in order to generate a module this way?


###Some additional notes:

When online:
$module = JModuleHelper::getModule('mod_login', ''); :
If I have a mod_login module created and published in modules manager, then the above code will render that module. (haven't tried with having 2 or more modules to see which one it will pick).

$module = JModuleHelper::getModule('mod_login', ''); :
With a trashed module, nothing will be rendered.

$module = JModuleHelper::getModule('mod_login'); :
Nothing will be rendered.

$module = JModuleHelper::getModule('mod_login', 'TEST'); :
With no mod_login module with that title, nothing will be rendered.

$module = JModuleHelper::getModule('mod_login', 'TEST'); :
With a mod_login module with that title, the TEST mod_login module will be rendered (and I assume it should also obey to any assignments like menu items/ACL that module will have).

On localhost:
$module = JModuleHelper::getModule('mod_login'); :
Will create a fresh mod_login instance, everything will work.

$module = JModuleHelper::getModule('mod_login', 'NON EXISTING MODULE TITLE'); :
Will create a fresh mod_login instance, everything will work.


Related content:

  • 1
    Well, I didn't use the correct phrase - it actually doesn't work at all. I am currently editing my question, adding a few extra info and will rephrase that part. – FFrewin Jul 17 at 8:42
  • I think I am coming to the conclusion that this is caused by the LSCache extension for Joomla. I posted an issue on their github repo and wait for their response. – FFrewin Jul 17 at 16:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.