Drupal 通过API动态的加入样式文件
生活随笔
收集整理的這篇文章主要介紹了
Drupal 通过API动态的加入样式文件
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
前面幾篇文章中講到關于樣式的載入方式。已經(jīng)了解到能夠通過 theme.info 載入樣式文件,但都須要更新緩存才干夠使用。因些這樣子沒有辦法動態(tài)的載入一些樣式文件,在DP中提供了兩個API操作樣式文件?drupal_add_css 、 drupal_get_css
這里。仍然是以 mytheme 為主題。看下面演示樣例:
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_get_css();}}總結
以上是生活随笔為你收集整理的Drupal 通过API动态的加入样式文件的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 智迪科技携手海通安恒,启动SAP实施项目
- 下一篇: apache+mod_wsgi+djan