How to get params value of plugin in component area in joomla2.5?

I tried to get plugin params in component area , but I did not get the result.

In any case, to get the values.

+4
source share
3 answers

Let this help you - Read more

JPluginHelper::getPlugin($type, $plugin) // It will return the plugin

Example -

 $plugin = JPluginHelper::getPlugin('authentication', 'ldap'); //$params = new JParameter($plugin->params);//backward compatibility $params = new JRegistry($plugin->params);//Joomla 1.6 Onward echo $params->get('param_name','default_value'); 

$params will function as a regular JParameter object and allow you to get values.

Note. Use JRegistry instead of JParameter

+12
source

JParameter deprecated in Joomla v1.6.x, Joomla v2.5.x and Joomla v3.0.x .. link

If you want to decode the params value, use JRegistry instead of JParameter

Example

 $plugin = JPluginHelper::getPlugin('system', 'sslredirect'); $params = new JRegistry($plugin->params); echo $params->get('param_name','default_value'); 

Resignation message in parameter.php

 // Deprecation warning. JLog::add('JParameter::__construct is deprecated.', JLog::WARNING, 'deprecated'); 
+12
source

Here is a snippet of Joomla code in PHP that allows you to access plugin options anywhere inside Joomla

 // Get plugin 'my_plugin' of plugin type 'my_plugin_type' $plugin = JPluginHelper::getPlugin('my_plugin_type', 'my_plugin'); // Check if plugin is enabled if ($plugin) { // Get plugin params $pluginParams = new JRegistry($plugin->params); $param1 = $pluginParams->get('param1'); $param2 = $pluginParams->get('param2'); $param3 = $pluginParams->get('param3'); } 
0
source

Source: https://habr.com/ru/post/1443159/


All Articles