You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/templates/globals/preload-replacement.md
+21
Original file line number
Diff line number
Diff line change
@@ -36,3 +36,24 @@ A common usage for preload replacements is to hold the Channel short name(s), to
36
36
<h2>{title}</h2>
37
37
{body}
38
38
{/exp:channel:entries}
39
+
40
+
### Conditional Usage
41
+
42
+
You may want to combine this with EE's Live Preview functionality, so that your template can show content while you're in the control panel that you might not want to have appear on the live site:
Make sure you substitute "template_group" and "css_template" with the name of your actual template group and CSS template.
21
25
22
26
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:
In many respects, this variable works much like the {path=''} global variable. However, there are some special considerations for the stylesheet variable:
- Pages that are linked through the stylesheet tag will **not** be parsed as normal Templates. ExpressionEngine Tags and PHP inside the Template will not be parsed. The Template will be sent exactly as it is stored. This means that your CSS files will be much more light-weight as they do not require the use of ExpressionEngine's template parser.
29
-
- When the stylesheet tag is used, "text/css" MIME headers will be sent to the browser. Some browsers will not treat the CSS file as such without these headers.
34
+
In many respects, this variable works much like the `{path=''}` global variable. However, there are some special considerations when the stylesheet URL (?css=) is used:
35
+
36
+
- Pages that are linked and served via the stylesheet URL will **not** be parsed as normal Templates. ExpressionEngine Tags and PHP inside the Template will not be parsed.
37
+
- The template will be sent exactly as it is stored. This means that your CSS files will be much more light-weight to serve, because they do not require the use of ExpressionEngine's template parser.
38
+
- The template must be set to Type CSS, and "text/css" MIME headers will be sent to the browser. Some browsers will not treat the CSS file as such without these headers.
39
+
- If the template is **not** set to be CSS, the server will report a 404 error rather than serve the file as mime type of HTML.
30
40
31
41
## Triggering a Stylesheet Via the URL
32
42
33
-
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 "channel_css" Template of the "channel" Template Group, you could point to it using the URL:
43
+
It is also possible to point to a stylesheet template by directly adding the "css" trigger word in the URL path. For instance, if your stylesheet is the "channel_css" template of the "channel" template group, you could point to it using the URL:
- Again, if the template is **not** set to be CSS, the server will report a 404 error rather than serve the file as mime type HTML.
48
+
- This could also cause a conflict if you have a real folder named "/css".
36
49
37
50
## Using Tags and PHP in a Stylesheet
38
51
39
-
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](templates/globals/path.md) to access your stylesheet. If you specify a template this way make sure that it is set to "CSS" as the Template Type.
52
+
Additionally, you can run your stylesheets through the full template parser so that tags and PHP can be used. To do so, just use a normal [path variable](templates/globals/path.md) to access your stylesheet. If you link to a template this way, make sure that it is set to "CSS" as the Template Type in order to get the CSS mime headers.
53
+
54
+
NO PARSING: `{stylesheet='template_group/css_template'}`
0 commit comments