0
votes

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.

2
WHen you say make an instance, do you mean you want it to show up in the list of modules in the module manager or do you want it to render?Elin
I wnat to show it up in the list of modules.Thanksuser1877095
Maybe u can disclose your problem to understand betterArun Unnikrishnan

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.