Skip to content

Commit e6fc45a

Browse files
authored
Merge pull request #955 from ExpressionEngine/7.dev
Push a few more updates live
2 parents feb4d7b + 1dae83d commit e6fc45a

File tree

2 files changed

+49
-7
lines changed

2 files changed

+49
-7
lines changed

docs/templates/globals/preload-replacement.md

+21
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,24 @@ A common usage for preload replacements is to hold the Channel short name(s), to
3636
<h2>{title}</h2>
3737
{body}
3838
{/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:
43+
44+
{preload_replace:channels="news|reviews"}
45+
{if is_live_preview_request}
46+
{preload_replace:status_tag=" status='open|archive|draft' "}
47+
{if:else}
48+
{preload_replace:status_tag=" status='open' "}
49+
{/if}
50+
51+
{exp:channel:entries
52+
channel="{channels}"
53+
limit="10"
54+
{status_tag}
55+
disable="category_fields|member_data|pagination"
56+
}
57+
<h2>{title}</h2>
58+
{body}
59+
{/exp:channel:entries}

docs/templates/globals/stylesheet.md

+28-7
Original file line numberDiff line numberDiff line change
@@ -17,23 +17,44 @@ The stylesheet global variable is meant for generating URLs for use when linking
1717

1818
{stylesheet='template_group/css_template'}
1919

20+
which will return this, (assuming a base URL of https://example.com/)
21+
22+
https://example.com/?css=template_group/css_template
23+
2024
Make sure you substitute "template_group" and "css_template" with the name of your actual template group and CSS template.
2125

2226
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:
2327

24-
<link rel="stylesheet" type="text/css" media="all" href="{stylesheet='channel/channel_css'}" />
28+
<link rel="stylesheet" type="text/css" media="all" href="{stylesheet='template_group/css_template'}" />
29+
30+
which will return
2531

26-
In many respects, this variable works much like the {path=''} global variable. However, there are some special considerations for the stylesheet variable:
32+
<link rel="stylesheet" type="text/css" media="all" href="https://example.com?css=template_group/css_template" />
2733

28-
- 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.
3040

3141
## Triggering a Stylesheet Via the URL
3242

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:
44+
45+
[https://example.com/css/channel/channel_css](https://example.com/css/template_group/css_template)
3446

35-
[https://example.com/css/channel/channel_css/](https://example.com/css/channel/channel_css/)
47+
- 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".
3649

3750
## Using Tags and PHP in a Stylesheet
3851

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'}`
55+
56+
https://example.com/?css=template_group/css_template
57+
58+
FULL PARSING: `{path='template_group/css_template'}`
59+
60+
https://example.com/template_group/css_template

0 commit comments

Comments
 (0)