如何访问文章中的模板颜色?

时间:2014-10-25 11:37:00

标签: php css twitter-bootstrap joomla

我对Joomla很新,使用版本3.3.6和默认的protostar模板(基于bootstrap)。我正在使用Sourcerer plugin将PHP代码插入到我的文章中。

现在我想访问模板颜色来设置表格边框的样式。在index.php内,我可以使用$this->params->get('templateColor')。但是,在文章中没有定义对象上下文。我看过variables and objects that are defined in sourcerer。到目前为止没有成功。

或者是否有另一种(更好的)方法在编辑器中动态使用模板颜色?

2 个答案:

答案 0 :(得分:1)

使用以下代码进行模板颜色

$app    = JFactory::getApplication();
$params = $app->getTemplate(true)->params;

$color  = $params->get('templateColor');

答案 1 :(得分:0)

尼克的回答是正确的。但是,我发现创建一个css类

更容易也可能更好
.templateColorBorder {
    border: 2px solid <?php echo $this->params->get('templateColor'); ?>;
}

index.php内。这样我就可以使用普通的html编辑器编辑文章,并将此类分配给我想要有彩色边框的单元格/表格,甚至不需要文章中的任何PHP代码。

<td class="templateColorBorder">