Note: This solution does not read from TV tags, but it’s an acceptable compromise.
Evo 1.0.3
In
Configuration -> Interface and Features, copy the value specified in ’Path to CSS file’, then empty this field. You will specify this value in our code.
In
Elements -> Plugins, open the TinyMCE plugin code for editing. Add the following immediately above the first $params statement:
// BEGIN RUNTIME CSS INJECTION
preg_match('/id\=(\d+)/', $_SERVER['QUERY_STRING'], $matches);
$top = $modx->getParentIds($matches[1]);
$top = (empty($top)) ? $matches[1] : array_pop($top) ;
$doc = $modx->getPageInfo($top, 0, 'alias');
$customparams = str_replace('[+pageid+]', $doc['alias'], $customparams);
// END RUNTIME CSS INJECTION
Then, click on the plugin’s configuration tab.
Add the following to your Custom Parameters text area:
content_css:
'/path/to/your/static/css/stylesheet.css,
/path/to/another/static/stylesheet1.css,
/path/to/your/page-specific/stylesheet/directory/[+pageid+].css',
Usage:
Place the value you copied from ’Path to CSS file’ into the content_css string, replacing the static path samples in the code. You can add additional ’static’ stylesheets if you want.
When creating your page-specific stylesheets, organize them into one directory on your server. Update the directory path sample in the code to reflect your page-specific stylesheet directory. Naming your stylesheets is important:
the stylesheet name must match the URL alias of the resource. For example, if I have a resource with a URL alias as ’my-great-page’, TinyMCE will look for a stylesheet called ’my-great-page.css’. One important note is that if the resource is nested in containers, TinyMCE will use the resource’s ultimate parent URL alias.
Hope this helps someone.
- Mike