2013-07-10 47 views
0

我编写自定义模块,例如,当模块用参数1调用时,模块返回1,当用2调用时,返回2 e.t.c.发送参数到Joomla模块

但我找不到任何文档,如何将参数从页面发送到模块。它我怎么称呼现在模块:

jimport('joomla.application.module.helper');        
$modules = JModuleHelper::getModules('NAME_OF_CUSTOM_POSITION'); 
$count_array = count($modules); 
if ($count_array >0) 
    { 
    $attribs['style'] = 'xhtml'; 
    echo JModuleHelper::renderModule($modules[0], $attribs); 
    }        
?> 

但我不知道如何发送PARAMS也没怎么收到他们我的模块中。

回答

1

我在我的自定义组件之一中使用了下面的代码,它对我有用。

$document = JFactory::getDocument(); 
$renderer = $document->loadRenderer('module');   
$params = array('style'=>'xhtml');   
$contents = ''; 
foreach (JModuleHelper::getModules('NAME_OF_CUSTOM_POSITION') as $mod) { 
    $registry = new JRegistry(); 
    $registry->loadString($mod->params); 
    $registry->set('paramname','paramvalue'); 
    $mod->params = (string)$registry; 
    $contents .= $renderer->render($mod, $params); 
} 
echo $contents; 
+0

以及我如何获得这个参数在我的模块?或者我应该在我的mod_module.php中使用$ params作为参数? – JohnDow

+0

@ VladislavIl'ushin:是的,你可以使用$ params变量来获得它。 – Irfan