Skip to content

Instantly share code, notes, and snippets.

@elioair
Last active November 20, 2021 21:24
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save elioair/d71b53f487f8ee77a058 to your computer and use it in GitHub Desktop.
Save elioair/d71b53f487f8ee77a058 to your computer and use it in GitHub Desktop.
Getting Joomla! module, template & plugin parameters.

==================================================== Getting Joomla! module, template & plugin parameters

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);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment