To create a subtheme, follow all 10 steps mention in this article. It includes instructions on how to add your own theme specific CSS files.
If you want them to load conditionally, add your own MYTHEMENAME_preprocess_HOOK
functions to ./MYTHEMENAME/template.php
in your subtheme folder.
After you add your changes, add the following lines of code in ./MYTHEMENAME/template.php
at the very bottom :
drupal_flush_all_caches();
drupal_theme_rebuild();
This should flush the cash and add your changes. Then, comment out these two lines and refresh your browsers. Your changes should now be included.
The easiest way to test whether your MYTHEMENAME_preprocess_HOOK
function is actually being used, is to add nothing but one of the following options to that function (and remove it when it generates output) :
echo 'MYTHEMENAME_preprocess_HOOK used'; // native PHP
var_dump('MYTHEMENAME_preprocess_HOOK used'); // native PHP
debug('MYTHEMENAME_preprocess_HOOK used'); // Drupal specific
If you don't want to clutter ./MYTHEMENAME/template.php
, you can also put your hooks in seperate files in the preprocess folder as described in the readme file.
TEMPLATE_preprocess_html() --> ./MYTHEMENAME/preprocess/preprocess-html.inc
TEMPLATE_preprocess_page() --> ./MYTHEMENAME/preprocess/preprocess-page.inc
TEMPLATE_preprocess_node() --> ./MYTHEMENAME/preprocess/preprocess-node.inc
Unfortunately, the documentation forgets to mention what would be suitable values for TEMPLATE
. As you can see in the code in the process folder of inherited themes, TEMPLATE
should be identical to MYTHEMENAME_alpha
. It took me hours to figure that out.
For example, your page hook would be something like this if it was put in the file ./MYTHEMENAME/preprocess/preprocess-page.inc
:
function MYTHEMENAME_alpha_process_page(&$vars) {
//debug($vars);
}