Joomla Asked by FFrewin on September 5, 2021
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 Asked on September 5, 2021 by user11034850
1 Asked on September 5, 2021 by chaosxmk
2 Asked on September 5, 2021 by marckson
0 Asked on September 5, 2021 by miasto
1 Asked on September 5, 2021 by norberto-gomes
1 Asked on September 5, 2021 by aheavyobject
2 Asked on September 5, 2021 by hamlet-kraskian
1 Asked on September 5, 2021 by webchun
0 Asked on September 5, 2021 by kirpal
1 Asked on February 7, 2021 by sajeeb-ahamed
1 Asked on February 5, 2021 by andrea-suriani
1 Asked on January 21, 2021 by lecraver
3 Asked on December 28, 2020 by wbdevlop
1 Asked on December 26, 2020 by exprove
1 Asked on December 23, 2020 by kiasaty
1 Asked on December 3, 2020 by n-h
0 Asked on November 11, 2020 by geoplous
Get help from others!
Recent Answers
Recent Questions
© 2023 AnswerBun.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP