Hello. This is more of a note than anything else. I was running in to an issue where my CSS files were not being served from the CDN. After tracing this back through file_create_url, cdn_file_url_alter, drupal_get_css, and template_preprocess_page, I have what I think may be an important tip.

In the event that you decide to implement a mytheme_preprocess_page() call in template.php, you will also need to re-add this line to your custom preprocess function:

$vars['styles'] = drupal_get_css();

Otherwise, the rewritten CDN paths for CSS files are not used, which means that all of your css files and background images will still be served locally.

Comments

rjbrown99’s picture

Status: Active » Fixed

This is just an FYI, so I am closing it out.

wim leers’s picture

Issue tags: +theme

Very interesting! Thanks for letting us know — I'm sure this will come in handy to some theme developers some day! :)

rjbrown99’s picture

One more note. If you are using the conditional_styles module, you need to re-pop that into the preprocess_page as well.

$vars['styles'] .= $vars['conditional_styles'] = variable_get('conditional_styles_' . $GLOBALS['theme'], '');

Per #690460: Conditional styles not added to $styles?, comment #1.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

wim leers’s picture

Title: CSS rewriting and template_preprocess_page » Document problem with CSS file URL rewriting when using template_preprocess_page()