Functions/queue css

< Functions(Redirected from Theme API/queue css)

The queue_css() helper function is used to add stylesheets that will be printed by display_css. This is the preferred method for both theme and plugin writers to add CSS to a page.

For stylesheets added with this function to be displayed, the queue_css() call must come before the display_css() call. This means you can generally call queue_css() in the following places:

Usage

<?php
queue_css($file, 
          $media = 'all',
          $conditional = false,
          $dir = 'css');
?>

Arguments

  • $file (string|array) (required) The name of the CSS file to include. You should omit the ".css" extension from the filename. You can also specify an array of filenames, and each file will be included.
  • $media (string) (optional) (default: 'all') The media type the stylesheet should apply to. This is output as the "media" attribute of the link tag.
  • $conditional (string) (optional) (default: false) An IE-style conditional comment. This is generally used to include IE-only styles. The default is to include no conditional.
  • $dir (string) (optional) (default: 'css') The theme directory that will be searched for the CSS file. The default is the "css" directory.

Return Value

None.

Output

None. display_css() is the corresponding helper that outputs the tags; all Omeka pages will normally call display_css().

Example(s)

Including a Single Stylesheet

<?php queue_css('styles'); ?>

This will cause a call to display_css() to include a tag like:

<link href="http://your-path/css/styles.css" media="all" rel="stylesheet" type="text/css">

Including Multiple Stylesheets

<?php queue_css(array('style1', 'style2', 'style3')); ?>

This is equivalent to calling the above example three times, once for each stylesheet.

Source File / Version

  • application/helpers/AssetFunctions.php in Omeka 1.3.