PHP tags and EE tags aren’t parsed in my stylesheet
When using ExpressionEngine to link to stylesheets, the typical way to do this is by using the standard http://expressionengine.com/?css=weblog/weblog_css type syntax. When EE uses the http://expressionengine.com/?css= tag, two special things happen:
1. The stylesheet content is sent with the “text/css” header in order to tell the browser that the content is a stylesheet. This is necessary on some browsers such as Mozilla since the stylesheet is not a standard file with a .css extension.
2. ExpressionEngine skips over most of the Template engine and simply serves the stylesheet content in a “raw” form. This is done to make the stylesheet be served as quickly as possible and with the least server overhead possible. It also means that PHP and EE tags are not parsed in the Template.
If you need to have PHP or EE tags parsed in your CSS then you have two choices:
a. You could use the http://expressionengine.com/weblog/weblog_css/ syntax to link to the stylesheet. That variable will cause EE to parse the Template as normal. However, the stylesheet will not be sent with the “text/css” header and thus could cause problems in some browsers.
b. Use your stylesheet as normal and link to it normally with the http://expressionengine.com/?css= syntax. For the styles that require PHP or EE tags, you can simply place those in the <head> of your regular pages/Templates and enclose the styles in <style> tags like normal. With this method you have the dynamic styles embedded in your regular pages but still link to the external stylesheet for the majority of the CSS.
Category: Templates, PHP, Technical Issues, Troubleshooting
