Nasıl css drupal son yüklenecek eklerim?

4 Cevap php
drupal_add_css('override/files/style.css');

Bu tür demeçler, css son yüklendiğinden emin olamaz

Ben hile nasıl yapabilirim?

4 Cevap

CSS sistem tablosunda saklanır arama yapıyor modül veya tema ağırlığına büyük ölçüde bağlıdır sırası drupal_add_css () denir, katma alır. Drupal.org's instructions on changing module weight da temalar için çalışır.

Drupal_add_css () sırasını belirleyen diğer bir faktör sadece içeren fonksiyon Drupal kod denir sıradır. template_preprocess_page (), örneğin, her düğüm sayfaya gider, çünkü) (template_preprocess_node sonra denir.

Eğer ninesixty tema template.php tema dosyasına bakarsanız bir çözüm bulacaksınız.

Aşağıdaki fonksiyon theme_preprocess_page kanca denir:

function ninesixty_css_reorder($css) {
  global $theme_info, $base_theme_info;

  // Dig into the framework .info data.
  $framework = !empty($base_theme_info) ? $base_theme_info[0]->info : $theme_info->info;

  // Pull framework styles from the themes .info file and place them above all stylesheets.
  if (isset($framework['stylesheets'])) {
    foreach ($framework['stylesheets'] as $media => $styles_from_960) {
      // Setup framework group.
      if (isset($css[$media])) {
        $css[$media] = array_merge(array('framework' => array()), $css[$media]);
      }
      else {
        $css[$media]['framework'] = array();
      }
      foreach ($styles_from_960 as $style_from_960) {
        // Force framework styles to come first.
        if (strpos($style_from_960, 'framework') !== FALSE) {
          $framework_shift = $style_from_960;
          $remove_styles = array($style_from_960);
          // Handle styles that may be overridden from sub-themes.
          foreach ($css[$media]['theme'] as $style_from_var => $preprocess) {
            if ($style_from_960 != $style_from_var && basename($style_from_960) == basename($style_from_var)) {
              $framework_shift = $style_from_var;
              $remove_styles[] = $style_from_var;
              break;
            }
          }
          $css[$media]['framework'][$framework_shift] = TRUE;
          foreach ($remove_styles as $remove_style) {
            unset($css[$media]['theme'][$remove_style]);
          }
        }
      }
    }
  }

  return $css;
}

Ağırlık özelliğini kullanın:

drupal_add_css(drupal_get_path('theme', 'mytheme') . '/css/styles.css', array('weight' => 999));

Not: temanızın bilgi eklendi CSS her zaman son olacak, bu yüzden temanın bilgi dosyasında bildirilen senin stylesheets'e ağırlığını değiştirmek için daha önce olduğu gibi aynı işlevi kullanır.

Drupal 6 kullanım için:

drupal_add_css('site.css', 'theme', '', array('weight' => 999))