3

What is the newer syntax to replace the deprecated JApplication::getCfg()?

The docs don't specify the replacement in the deprecation notice.

Thanks!

3

This will get the config settings for you.

$config = JFactory::getConfig();
echo 'Site name is ' . $config->get( 'sitename' );
0

That's odd, it does in version 3.4.8, the syntax is the same but the name of the method has been shortened to just get If you jump to the original class in your IDE this is the old getCfg() method:

 /**
 * Gets a configuration value.
 *
 * @param   string  $varname  The name of the value to get.
 * @param   string  $default  Default value to return
 *
 * @return  mixed  The user state.
 *
 * @since   3.2
 * @deprecated  4.0  Use get() instead
 */
public function getCfg($varname, $default = null)
{
    return $this->get($varname, $default);
}

As you can see getCfg('someVarName') can simply be replaced with get('someVarName').

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.