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



我已经使用Joomla 3.6启动了一个新项目,但我遇到了这个问题。我在模板样式布局中添加了一些字段。我在模板索引中恢复.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');

最新更新