Hi,
How can I create CSS using PHP, where things like categoryIDs have been looked up?
Background: I'm currently upgrading a custom Theme (based on Clean, Moodle 2.7) to manage 100+ banners, based on the second level category (regardless of how deep in the hierarchy the course is). I've got this working (the hard bit basically done - looking up the category IDs, and adding them to the body classes and the basic CSS to implement them).
The relevant banner images will be inserted in a subdirectory in the theme folder, and simply named [categoryID].jpg.
To implement the 100+ banners requires 2 CSS definitions to be applied for each - so the CSS file will end up with 200+ CSS definitions, of which only 2 will ever be used at any 1 time. The only difference between the CSS definitions in each case will be the categoryID references.
For example, one of the CSS definitions looks like this:
.category-7 #left-main-row {
background-image: url([[pix:theme|category_banners/7]]);
}
If I can use a variable in place of the 7, based on lookups and output from PHP, it will save a lot unnecessary CSS.
Or is this not possible due to caching of styles?
Or do I loose caching ability, and therefore end up much worse off?
I've tried adding a style sheet in the config that points to a PHP file instead of a CSS file with no result.
Is writing CSS in-page headers for the layouts a better option - avoiding and not affecting Theme CSS caching entirely?
Any help much appreciated as to the right approach - even if it means static CSS at the end of the day if that is the best option... That's what I need to know.