I have created a component and need to get a constant value in the component administrator and list the item according to it. I have tried different ways to get the constant value in the display()
function in 'view.html.php'. I am expecting the value will be available in the default.php with $this
.
I have defined the constant in the configuration.php file, a URL is supposed to be define.
define('CONSTANTVALUE', 'the URL string');
in the display()
function,
$config = JFactory::getConfig();
$constantvalue = $config->get('CONSTANTVALUE');
$this->constantvalue= $constantvalue;
Seems this is not working. Then, I have tried:
JFactory::getApplication()->get('CONSTANTVALUE');
That is also not working.
I have referred to this thread, https://stackoverflow.com/questions/21702981/joomla-3-how-to-get-value-from-configuration-file
How can I get the constant from configuration to component view file?
configuration.php
.getParams()
is a static method sorry, correctly again:ComponentHelper::getParams()
, however in your own component you will get the component params via your Model as it is given in the document’ link above.