rynhe
rynhe

Reputation: 2529

How to get Module params in component area in joomla2.5

I want to get the module params in component area in joomla 2.5

Here my code :

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

I try to print the $moduleParams...Its display nothing.
I got this code from the website http://www.themepartner.com/blog/25/retrieving-plugin-module-component-and-template-parameters/

Is there anyother way to get the params using the module name.

Upvotes: 2

Views: 9817

Answers (3)

3ehrang
3ehrang

Reputation: 629

For Joomla 3 you just need to do:

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

Upvotes: 3

Rakesh Sharma
Rakesh Sharma

Reputation: 13728

for joomla 1.6 and higher

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

Hope this help cause jparameter is deprecated in j1.5 higher

You missed the actual link i think for 1.7 is http://www.themepartner.com/blog/56/get-joomla-17-plugin-module-component-and-template-parameters/

Upvotes: 5

rynhe
rynhe

Reputation: 2529

I found the mistake

here the correct code

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

Problem is jimport( 'joomla.html.parameter' ); is missed

Upvotes: 1

Related Questions