On this page
Tag
Last updated on
30 April 2025
Tag is the most intuitive replacement method.
Important Tags no longer use the /* {{tag}} */HEX/* {{/tag}} */ syntax. Please refer to the new, simpler usage below.
It will match up a field color for a scheme to a tag in the stylesheet. Tags look like this:
color: #FFFFFF; /* t:tag-name */
Configuring tag
Basic $color in hook_color():
return array(
'replacement methods' => array(
/**
* 'tag' method
* Replaces custom tags in stylesheet based on fieldname.
*/
'tag' => TRUE,
),
/**
* 'fields' (Required)
* The machine-readable names of color fields. The name will help you
* and your theme users identify colors.
*/
'fields' => array('background', 'text'),
/**
* 'premade schemes' (Required)
* A list of pre-made schemes that will be available for install by default.
* The scheme name, human-readable, is followed by hex values separated by
* commas (no spaces). The colors are to be ordered respectable to 'fields'.
*/
'premade schemes' => array(
'Ash' => array('background' => '#464849', 'text' => '#2f416f'),
'Aquamarine' => array('background' => '#55c0e2', 'text' => '#082f36'),
'Belgian Chocolate' => array('background' => '#d5b048', 'text' => '#6c420e'),
'Blue Lagoon' => array('background' => '#0072b9', 'text' => '#027ac6'),
),
/**
* 'default scheme' (Required)
* A scheme name from one in your 'premade schemes' list.
*/
'default scheme' => 'Ash',
/**
* 'reference scheme' (Required)
* A scheme name from one in your 'premade schemes' list.
* On schemes which use the 'base', 'link' or 'text' flag, always mention this.
* Other schemes will be shifted against the fields of the reference one.
*/
'reference scheme' => 'Blue Lagoon', // just for kicks, you may not need but be safe.
/**
* 'stylesheets' (Required)
* Path to your CSS file relevant to the root of your theme directory.
* Can mention an array of stylesheets.
*/
'stylesheets' => array('color/style.css'),
);
Inside color/style.css:
body {
background: #FFFFFF; /* t:background */
color: #000000; /* t:text */
}
After generated
When schemes are generated we will have 4 generated schemes. Here are 2 picked randomly:
Ash:
body {
background: #464849;
color: #2f416f;
}
Belgian Chocolate:
body {
background: #d5b048;
color: #6c420e;
}
Notes
- Tag must be on same line as attribute.
- Tags cannot have spaces. Use dashes (-) instead.
body-background - The tag must be made after the semicolon (;) of an attribute.
- The tag must be enclosed in comments.
/* like-this */ - This is supposed to support attribute declarations with multiple values, like
#00ff00 url('logo.gif') no-repeat fixed center; - Currently only supports hex colors.
Troubleshooting
- If your schemes are generated and nothing is changing, please make sure you add color = TRUE to your
TEMPLATENAME.infofile. - If using shift+tag, for color you don't want shifted/replaced, it's easy, see about Don't touch!
Help improve this page
Page status: Not set
You can:
You can:
- Log in, click Edit, and edit this page
- Log in, click Discuss, update the Page status value, and suggest an improvement
- Log in and create a Documentation issue with your suggestion