Joomla 3.x 从样式 sheet 获取参数到自定义文章布局

Joomla 3.x get params from style sheet to custom article layout

我已经使用 Joomla 3.6 开始了一个新项目,但我仍然遇到这个问题。 我在模板样式布局中添加了一些字段。 我使用

在模板 index.php 中检索
$logo           = $this->params->get('logo');
$navposition    = $this->params->get('navposition');
$headerImage    = $this->params->get('headerImage');

但我没有在新创建的自定义文章替代布局中得到它。 如何在自定义布局中调用它?

您不能使用相同的方法从任何地方检索模板参数。为此,您可以使用此方法

$app        = JFactory::getApplication();//Initiate the Application class
$template   = $app->getTemplate(true);//get the current template
$params     = $template->params;// get the template params
//Retrieve the variables using $params
$logo           = $params->get('logo');
$navposition    = $params->get('navposition');
$headerImage    = $params->get('headerImage');