I like to customize the Manager to help guide my clients and to amuse myself.
Manager Customization is a great tool, but there are some things only a stylesheet can do, so I wrote a plugin that sets data-attributes on the body tag, so they can be styled by CSS.
The attributes set are data-resource-id and data-resource-template. This is done in a script that the plugin loads. For demonstration purposes, the plugin also loads a stylesheet.
Note that the script is a chunk so I can set values from the plugin. The stylesheet is a chunk here, but could be a file or generated Sass.
<script>
document.addEventListener('DOMContentLoaded', function () {
let body = document.querySelector('body');
body.dataset.resourceId = [[+id]];
body.dataset.resourceTemplate = [[+template]];
});
</script>
And the demo stylesheet. Use your own template and resource ids.
<style>
/* make the pagetitle blue for this template */
body[data-resource-template="105"] #modx-resource-header {
color: blue;
}
/* except this one, which will be red */
body[data-resource-template="105"][data-resource-id="820"] #modx-resource-header {
color: red;
}
</style>
I guess the demo stylesheet is just an example on how to target the elements you want to change via CSS.
So this example just turns the h2 red. Well… to be more precise: it does not really do that, bc the h2 wraps another h2 which you should target in your styles. And prepare yourself to use the !important rule a lot, as overriding the default styles often not works without doing so.
Setting those data-attributes is a neat idea imho!
Where is the nested H2 tag coming from? That doesn’t seem like a good idea. I would wager that it’s not allowed according to HTML5 standards. According to W3C, heading tags should include only phrasing content (3 Semantics, structure, and APIs of HTML documents — HTML5), not flow content like other heading tags.