Getting error while using new JParameter($plugin->params); in joomla 3.0
-
03-07-2021 - |
Question
I have used the following code in joomla 3.0 for getting plugin parameters.
new JParameter($plugin->params);
But I am getting error.
Please any one can help me.
Regards, Jaylani.
Solution
As JParameter was using JRegistry, here is a work around:
$params = new JRegistry();
$params->loadString($module->params);
$params->get('param_name');
OTHER TIPS
Removed classes
- JParameter (use JForm instead or, in most circumstances, JRegistry - for example to retrieve in a component a plugin parameter).
A little late, but for everyone else who stumbles upon this:
Use:
json_decode($plugin->params);
I found this along with lots of other useful informations about the changes in Joomla 3.0 here: techjoomla.com
Try the following instead of JParameter (deprecated class in J3):
jimport('joomla.html.parameter');
$params = new JInput();
$params->get('params');
This might answer your question and solve your issue.
JParameter is deprecated use Registry.
use Joomla\CMS\Plugin\PluginHelper;
use Joomla\Registry\Registry;
$plugin = PluginHelper::getPlugin('plg_Type', 'plg_Name');
$plgParams = new Registry($plugin->params);
$param = $plgParams->get('your_param_name', 'default_value')
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow