2013-03-17, 07:26 AM
This offers a shorthand way to write CSS. For instance, instead of writing this:
You could write this:
It's incredibly easy to do and only requires a few lines of code.
Open up admin/modules/style/themes.php.
Find (around line 1900):
Add before:
To add more variables, add new array entries. I just used my two test variables. These only work on the Advanced Editor and will be replaced when you save it.
If you want it to apply to new stylesheets:
Find (around line 2260):
Add before:
I tried making this into a plugin but always broke my Theme Editor. I hope this helps you.
.class
{
background: url('images/imagesubdir/image.png');
other css
}
.anotherclass
{
background: url('images/imagesubdir/image.png');
more css
}
You could write this:
.class
{
background: {BG};
other css
}
.anotherclass
{
background: {BG};
more css
}
It's incredibly easy to do and only requires a few lines of code.
Open up admin/modules/style/themes.php.
Find (around line 1900):
// Now we have the new stylesheet, save it
$updated_stylesheet = array(
"cachefile" => $db->escape_string($stylesheet['name']),
"stylesheet" => $db->escape_string(unfix_css_urls($mybb->input['stylesheet'])),
"lastmodified" => TIME_NOW
);
Add before:
$replace = array(
"{BG}" => "black",
"{TH}" => "blue");
$mybb->input['stylesheet'] = strtr($mybb->input['stylesheet'], $replace);
To add more variables, add new array entries. I just used my two test variables. These only work on the Advanced Editor and will be replaced when you save it.
If you want it to apply to new stylesheets:
Find (around line 2260):
// Add Stylesheet
$insert_array = array(
'name' => $db->escape_string($mybb->input['name']),
'tid' => intval($mybb->input['tid']),
'attachedto' => implode('|', array_map(array($db, "escape_string"), $attached)),
'stylesheet' => $db->escape_string($stylesheet),
'cachefile' => $db->escape_string(str_replace('/', '', $mybb->input['name'])),
'lastmodified' => TIME_NOW
);
Add before:
$replace = array(
"{BG}" => "black",
"{TH}" => "blue");
$stylesheet = strtr($stylesheet, $replace);
I tried making this into a plugin but always broke my Theme Editor. I hope this helps you.
Please don't PM me for support.