2012-08-29 28 views
2

我想在分量區中的模塊PARAMS中的Joomla 2.5如何獲得在組件面積模塊PARAMS在joomla2.5

這裏我的代碼:

jimport(「joomla.application.module .helper');
$ module = & JModuleHelper :: getModule('mod_module');
$ moduleParams = new JParameter($ module-> params);
print_r($ moduleParams);

我試着打印$moduleParams ......它的顯示什麼都沒有。
我從網站得到了這段代碼http://www.themepartner.com/blog/25/retrieving-plugin-module-component-and-template-parameters/

有沒有其他的方法來使用模塊名來獲取參數。

回答

1

我發現這個錯誤

這裏正確的代碼

jimport( 'joomla.application.module.helper');
jimport('joomla.html.parameter');
$ module = & JModuleHelper :: getModule('mod_randomads');
$ moduleParams = new JParameter($ module-> params);

問題是jimport('joomla.html.parameter');錯過

+0

打我吧:)高興你得到它固定 – Lodder

5

爲Joomla 1.6和更高

jimport('joomla.application.module.helper'); 
    $module = JModuleHelper::getModule('mod_name'); 
    $moduleParams = new JRegistry(); 
    $moduleParams->loadString($module->params); 
    $param = $moduleParams->get('paramName', 'defaultValue'); 

希望這有助於事業jparameter在j1.5更高

不贊成你錯過了實際聯繫我認爲1.7是http://www.themepartner.com/blog/56/get-joomla-17-plugin-module-component-and-template-parameters/

+0

ThemePartner實際上關閉了他們的網站,我一直在尋找這個頁面。最後在這裏得到一個檔案:http://web.archive.org/web/20131001163031/http://www.themepartner.com/blog/56/get-joomla-17-plugin-module-component-and-template-參數/ –

2

對於Joomla 3你只需要做:

$module = JModuleHelper::getModule('mod_name'); 
$moduleParams = new JRegistry($module->params); 
$param = $moduleParams->get('param_name', 'default_value'); 
相關問題