0

我创建了一个组件,需要在组件管理员中获取一个常量值,并根据它列出项目。我尝试了不同的方法来获取 'view.html.php' 中的 'display()' 函数中的常量值。我期望该值将在带有 $this 的 default.php 中可用。

我在 configuration.php 文件中定义了常量,应该定义一个 URL。

define('CONSTANTVALUE', 'the URL string'); 

在 display() 函数中,

 $config = JFactory::getConfig();
 $constantvalue = $config->get('CONSTANTVALUE');
 $this->constantvalue=  $constantvalue;

似乎这不起作用。

然后,我试过了

JFactory::getApplication()->get('CONSTANTVALUE');

那也行不通。

我已经提到了这个线程,Joomla 3 - 如何从配置文件中获取价值?

如何从配置中获取常量到组件视图文件?

4

0 回答 0