Last Updated: April 19, 2016
·
4.587K
· anriettec

Getting Joomla! module, template & plugin parameters

Originally this was posted by Theo van der Zee on the site ThemePartner.

But his site has been taken offline and I have been struggling to find this vital information. Thanks to WebArchive.org, I have found it.

Here is the info for those that don't want to follow the link (copied verbatim, of course):

Plugin parameters from inside a plugin

$param = $this->params->get('paramName', defaultValue);

Plugin parameters from outside a plugin

$plugin = JPluginHelper::getPlugin('editors', 'codemirror'); $pluginParams = new JRegistry(); $pluginParams->loadString($plugin->params); $param = $pluginParams->get('paramName', 'defaultValue');

Module parameters from inside a module

$param = $params->get('paramName', 'defaultValue');

Module parameters from outside a module

$module = JModuleHelper::getModule('banners'); $moduleParams = new JRegistry(); $moduleParams->loadString($module->params); $param = $moduleParams->get('paramName', 'defaultValue');

Component parameters from inside a component

$app = JFactory::getApplication('site'); $componentParams = $app->getParams('com_content'); $param = $componentParams->get('paramName', defaultValue);

Component parameters from outside a component

$app = JFactory::getApplication('site'); $componentParams = $app->getParams('com_example'); $param = $componentParams->get('paramName', defaultValue);

### Template parameters from inside a template

$param = $this->params->get('paramName', defaultValue);

Template parameters from outside a template

$app = JFactory::getApplication('site'); $template = $app->getTemplate(true); $param = $template->params->get('paramName', defaultValue);