Получение параметров плагина в модуле Joomla 3

Yesterday I was coding one new module and I needed to get one enabled plugin`s parameters. Yeah, they are saved in database, you can get them by mysql requests. But It`s better to use Joomla 3 native classes and methods. Let`s have a look, how it works.  

To get any plugin parameters in Joomla 3 module code it`s time to use api class JPluginHelper, get plugin`s data in array $plugin by using method getPlugin like this:

$plugin = JPluginHelper::getPlugin('content', 'sdc');

While using it you must specify plugin`s type, like my "сontent", and plugin`s name which parameters you want to get, I use "sdc", it is my Simple Download Counter for Joomla 3 system name. 

Then if var $plugin is present, array  $pluginParams gets all parameters inside. 

if ($plugin) {
$pluginParams = new JRegistry($plugin->params)
$downfolder = $pluginParams->get('downfolder').'/'; } 

Now you can get any parameter which you want,  for example, my request $pluginParams->get('downfolder') gets Simple Download Counter plugin`s download folder which administrator specified in admin panel. That`s all for now. 

If you like this - share it with your friends. That would be the best "donation" for me!


Or just buy me a beer :-)

If you want to ask question or comment - login by using your favourite social network

 

Add comment