Drupal joins style files dynamically via API

Source: Internet
Author: User
Tags joins drupal

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.