Modlular Theme Support

Table of Contents

  1. What is a css theme?

This is a RFC for a modular theme support. The RFC is what i think should be better for sanely handling themes, but is possible that i'm missing a lot of points, so please review.

What is a css theme?

A css theme is:

  • style.php
  • vars.php - where PHP variables are defined
  • core.php - core CSS code of the app / site
  • $nav.php - the navbar

A barebone style.php looks like

/* PHP functions for client cache, whatever */
/* PHP function for locale, ... */

theme_include_once() is a wrapper around include_once() that check if a file is available, if not it picks the one in default/css. Like flexy does for the rest of theme.

Isn't it very simple? yep this is simple because it is generic. Further modularization could be done linking layout.php and common.php instead of core.php.

As you can see i've removed style.local.php. Why? Because it was an easy workaround that could help someone but doesn't solve anything for everyone (or the most at least). Let's have an example:

  • SGL put style.local.php include in the first <?php ?> block, just before the css code.
  • A wants to have the css code of his apps separated from the sgl one so it put it in style.local.php. And he is happy.
  • B wants the same that A but his code override some sgl code. But it don't works for him. "WTF???" is B screaming loud, "the FSCKED sgl code is overriding mine!". B resolves it moving the call to style.local.php on the second <?php ?> block.
  • C wants to override some things but at the same time want to add some php variables so that they can be used by sgl css code too. C practices yoga so he doesn't scream but it is dissapointed of adding another include_once() for style2.local.php

2 of 3 people are not happy with out of the box style.local.php because it is not generic. So if you need something special just add theme_include_once() / include_once() in your own application and since every file now is a php file you can put it everywhere you want.