drupal_add_css

Хочешь помочь с переводом? Это очень просто и быстро. Лишь зарегистрируйся, и можешь тут же начать переводить.

includes/common.inc, строка 1552

Версии
5 – 6
drupal_add_css($path = NULL, $type = 'module', $media = 'all', $preprocess = TRUE)

Adds a CSS file to the stylesheet queue.

What does this actually mean? CSS preprocessing is the process of aggregating a bunch of separate CSS files into one file that is then compressed by removing all extraneous white space.

The reason for merging the CSS files is outlined quite thoroughly here: http://www.die.net/musings/page_load_time/

'Load fewer external objects. Due to request overhead, one bigger file
just loads faster than two smaller ones half its size.'

However, you should *not* preprocess every file as this can lead to redundant caches. You should set $preprocess = FALSE when:

  • Your styles are only used rarely on the site. This could be a special admin page, the homepage, or a handful of pages that does not represent the majority of the pages on your site.
Typical candidates for caching are for example styles for nodes across the site, or used in the theme.

Параметры

$path (optional) The path to the CSS file relative to the base_path(), e.g., /modules/devel/devel.css.

$type (optional) The type of stylesheet that is being added. Types are: module or theme.

$media (optional) The media type for the stylesheet, e.g., all, print, screen.

$preprocess (optional) Should this CSS file be aggregated and compressed if this feature has been turned on under the performance section?

Возвращаемое значение

An array of CSS files.

Связанные темы

▾ 23 функции вызывают drupal_add_css()

aggregator_menu in modules/aggregator/aggregator.module
Реализация hook_menu().
block_admin_display in modules/block/block.module
Generate main block administration form.
book_menu in modules/book/book.module
Реализация hook_menu().
chameleon_page in themes/chameleon/chameleon.theme
color_scheme_form in modules/color/color.module
Конструктор формы. Возвращает форму конфигурирования.
comment_render in modules/comment/comment.module
Отображает комментарии.
drupal_get_css in includes/common.inc
Returns a themed representation of all stylesheets that should be attached to the page. It loads the CSS in order, with 'core' CSS first, then 'module' CSS, then 'theme' CSS files. This ensures proper cascading of styles...
drupal_maintenance_theme in includes/bootstrap.inc
Enables use of the theme system without requiring database access. Since there is not database access no theme will be enabled and the default themeable functions will be called. Some themeable functions can not be used without the full Drupal API...
forum_page in modules/forum/forum.module
Menu callback; prints a forum listing.
forum_view in modules/forum/forum.module
Реализация hook_view().
help_main in modules/help/help.module
Menu callback; prints a page listing a glossary of Drupal terminology.
init_theme in includes/theme.inc
Инициализирует систему темизации и загружает тему.
node_menu in modules/node/node.module
Реализация hook_menu().
phptemplate_page in themes/engines/phptemplate/phptemplate.engine
Prepare the values passed to the theme_page function to be passed into a pluggable template engine. Uses the arg() function to generate a series of page template files suggestions based on the current path. If none are found, the default page.tpl.php...
poll_menu in modules/poll/poll.module
Реализация hook_menu().
search_form in modules/search/search.module
Render a search form.
system_menu in modules/system/system.module
Реализация hook_menu().
theme_color_scheme_form in modules/color/color.module
Theme color form.
theme_install_page in includes/theme.inc
tracker_page in modules/tracker/tracker.module
Menu callback. Prints a listing of active nodes on the site.
user_menu in modules/user/user.module
Реализация hook_menu().
watchdog_menu in modules/watchdog/watchdog.module
Реализация hook_menu().
_locale_string_language_list in includes/locale.inc
List languages in search result table

Код

<?php
function drupal_add_css($path = NULL, $type = 'module', $media = 'all', $preprocess = TRUE) {
  static $css = array();

  // Create an array of CSS files for each media type first, since each type needs to be served
  // to the browser differently.
  if (isset($path)) {
    // This check is necessary to ensure proper cascading of styles and is faster than an asort().
    if (!isset($css[$media])) {
      $css[$media] = array('module' => array(), 'theme' => array());
    }
    $css[$media][$type][$path] = $preprocess;
  }

  return $css;
}
?>
Войдите или зарегистрируйтесь, чтобы получить возможность отправлять комментарии

Вход в систему