I'm fairly new to Joomla, using version 3.3.6 with the default protostar template (based on bootstrap). I'm using the Sourcerer plugin to insert PHP code into my articles.
Now I want to access the template color to style the border of a table. Inside the index.php
I can just use $this->params->get('templateColor')
. However, inside the article there is no object context defined. I have had a look at the variables and objects that are defined in sourcerer . So far without success.
Or is there another (better) method of dynamically using template colors inside the editor?
Use the below code for template-color
$app = JFactory::getApplication();
$params = $app->getTemplate(true)->params;
$color = $params->get('templateColor');
Nick's answer is correct. However, I found out it's easier and probably better to just create a css class
.templateColorBorder {
border: 2px solid <?php echo $this->params->get('templateColor'); ?>;
}
inside index.php
. That way I can just edit the article using the normal html editor and assign this class to the cells/tables I want to have a colored border and don't even need any PHP code inside the article.
<td class="templateColorBorder">
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.