Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/36.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 如何访问文章中的模板颜色?_Php_Css_Twitter Bootstrap_Joomla - Fatal编程技术网

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

Php 如何访问文章中的模板颜色?,php,css,twitter-bootstrap,joomla,Php,Css,Twitter Bootstrap,Joomla,我是Joomla的新手,使用3.3.6版本和默认的protostar模板(基于引导)。我正在使用将PHP代码插入到我的文章中 现在我想访问模板颜色来设置表格边框的样式。在index.php中,我可以使用$this->params->get('templateColor')。但是,在文章中没有定义对象上下文。我已经看了这本书。到目前为止还没有成功 或者在编辑器中是否有另一种(更好的)动态使用模板颜色的方法?使用下面的模板颜色代码 $app = JFactory::getApplication

我是Joomla的新手,使用3.3.6版本和默认的protostar模板(基于引导)。我正在使用将PHP代码插入到我的文章中

现在我想访问模板颜色来设置表格边框的样式。在
index.php
中,我可以使用
$this->params->get('templateColor')
。但是,在文章中没有定义对象上下文。我已经看了这本书。到目前为止还没有成功


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

使用下面的模板颜色代码

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

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

尼克的回答是正确的。然而,我发现仅仅创建一个css类更容易而且可能更好

.templateColorBorder {
    border: 2px solid <?php echo $this->params->get('templateColor'); ?>;
}

@user1-它是否已经定义并不重要。为了安全起见,你应该自己定义它。我知道一些扩展开发人员使用
$mainframe
而不是
$app
;)
<td class="templateColorBorder">