문제

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?

도움이 되었습니까?

해결책

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top