Linking to Stylesheets

Stylesheet Global Variable

The stylesheet global variable is meant for generating URLs for use when linking to stylesheets. The basic syntax is this:

{stylesheet=template_group/css_template}

Make sure you substitute "template_group" and "css_template" with the name of your actual template group and CSS template.

The stylesheet variables is used exclusively in the CSS declaration in your pages. It must contain the template group/template name where your stylesheet is located:

<link rel="stylesheet" type="text/css" media="all" href="{stylesheet=weblog/weblog_css}" />

In many respects, this variable works much like the {path=''} global variable. However, there are some special considerations for the stylesheet variable:

Triggering a Stylesheet Via the URL

It is also possible to point to a stylesheet templates by directly adding a "css" trigger word in the URL. For instance, if your stylesheet is the "weblog_css" Template of the "weblog" Template Group, you could point to it using the URL:

http://www.example.com/index.php/css/weblog/weblog_css/

Using Tags and PHP in a Stylesheet

Additionally, you can allow your stylesheets to run through the full template parser so tags and PHP can be used. To do so, just use a normal path variable to access your stylesheet. If you specify a template this way make sure that it is set to "CSS Stylesheet" as the Template Type.

Top of Page

User Contributed Notes

Posted by: Ingmar Greil on 18 April 2008 6:56am
Ingmar Greil's avatar

If you are using this stylesheet global variable, {site_url} is the only variable that is parsed regardless.

You must have an ExpressionEngine license and have attained a forum rank of "Lab Assistant" (100 posts) to contribute notes to the User Guide