Reputation: 295
I have two custom components that reference an external database. In component1 I set the parameters necessary to connect to that external DB.
Is there I way that I can use the parameter set in component1 within component2?
my code within my model in component2:
$app = JFactory::getApplication();
$params = $app->getParams('com_component1');
advises me of a fatal error:
Fatal error: Call to undefined method JApplicationAdministrator::getParams() in /var/www....
Should I just stop being lazy and redefine the same parameters in component2, or is there a reasonable solution?
Upvotes: 2
Views: 1501
Reputation: 19743
Try using the following code.
$params = JComponentHelper::getParams('com_component1');
$test = $params->get('param_name');
To get parameters, you need to use JComponentHelper
, not JFactory
.
Upvotes: 3