How to get the params value of plugin in the component area in joomla2.5?
Asked Answered
N

3

7

I have tried to get the plugin params in the component area, but i didn't get the result.

Is there anyway to get the values.

Nippon answered 31/10, 2012 at 6:31 Comment(0)
N
19

May this will help you- Read more

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

For 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 like normal JParameter object and enable you to get values.

Note: Use JRegistry Instead of JParameter

Nutwood answered 31/10, 2012 at 6:37 Comment(1)
Use JRegistry instead of JParameter since Joomla 3Keyes
L
13

JParameter was deprecated in Joomla v1.6.x,Joomla v2.5.x & Joomla v3.0.x.. reference

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');

Deprecation message in parameter.php

// Deprecation warning.
JLog::add('JParameter::__construct is deprecated.', JLog::WARNING, 'deprecated');
Lyndsaylyndsey answered 20/11, 2013 at 10:47 Comment(0)
F
0

Here is a snippet of a Joomla code in PHP that let's you access plugin parameters 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');
}
Farlie answered 1/12, 2015 at 13:34 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.