In the previous articles, we talked about how styles are loaded. You have learned that you can load style files through Theme.info, but you need to update the cache to be able to use them. Because of this, there is no way to dynamically load some style files, the DP provides two API operation style files Drupal_add_css, drupal_get_css
Over here. is still subject to mytheme. Look at the following demo sample:
Function Template_preprocess_page (& $variables) {? $front _style = Path_to_theme (). ' /front-page.css ';? $path _style = Path_to_theme (). ' /path-'. Arg (0). CSS ';? if (file_exists ($front _style) && $variables [' Is_front ']) {?? $include _style = $front _style;?}? ElseIf (file_exists ($path _style)) {?? $include _style = $path _style;?}? if (Isset ($include _style)) {?? drupal_add_css ($include _style, ' theme ', ' All ', FALSE);?? $variables [' styles '] = Drupal_g Et_css ();? }}
Drupal joins style files dynamically via API