Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Joomla 3 - How to get value from configuration file?

I'm building a custom component and I just want to get a value from the global config in my controller. I can't find any information about how to do this.

Something like...

$config = JFactory::getConfig();
$this->_db = $config->get('db');
like image 888
BadHorsie Avatar asked Feb 11 '14 13:02

BadHorsie


1 Answers

The documentation on how to do it is slightly outdated:

http://docs.joomla.org/JFactory/getConfig

But if you check the code they actually drop the ampersand function:

https://github.com/joomla/joomla-cms/blob/staging/components/com_users/models/registration.php

$config = JFactory::getConfig();
$fromname = $config->get('fromname');

Also if you are trying to connect to the database you really can just use the DB object from JFactory.

$db = JFactory::getDbo();

Learn more about properly connecting to the database here:

http://docs.joomla.org/Accessing_the_database_using_JDatabase

like image 127
Chad Windnagle Avatar answered Oct 12 '22 13:10

Chad Windnagle