I would like to create an instance of a module through code by passing necessary parameters.,i.e., instead of adding from admin interface module manager,I want to add through code. how to do it? Please help me.
0
votes
2 Answers
0
votes
First of All your question was not exactly clear.
I guess you want to add the module things through code instead of the default include module option in template page.
If this is the case you can use the following code.
$document = &JFactory::getDocument();
$renderer = $document->loadRenderer('module');
$Module = &JModuleHelper::getModule('mod_fmDataGrid');
$Params = "param1=bruno\n\rparam2=chris";
$Module->params = $Params;
echo $renderer->render($Module);
The code will help you to render the module inside any component or module. Also you can pass the module parameters through the code.
Hope this may help you..
0
votes
Hi you may try this for creating instance of Module
$document = &JFactory::getDocument();
$renderer = $document->loadRenderer('module');
$params = array('style' => $style);
echo $renderer->render(JModuleHelper::getModule('mod_login'), $params);
Here i have taken mod_login module as sample. You may use your selected module at there.