Skip to content

Push a few more updates live #955

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Mar 4, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions docs/templates/globals/preload-replacement.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,24 @@ A common usage for preload replacements is to hold the Channel short name(s), to
<h2>{title}</h2>
{body}
{/exp:channel:entries}

### Conditional Usage

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:

{preload_replace:channels="news|reviews"}
{if is_live_preview_request}
{preload_replace:status_tag=" status='open|archive|draft' "}
{if:else}
{preload_replace:status_tag=" status='open' "}
{/if}

{exp:channel:entries
channel="{channels}"
limit="10"
{status_tag}
disable="category_fields|member_data|pagination"
}
<h2>{title}</h2>
{body}
{/exp:channel:entries}
35 changes: 28 additions & 7 deletions docs/templates/globals/stylesheet.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,23 +17,44 @@ The stylesheet global variable is meant for generating URLs for use when linking

{stylesheet='template_group/css_template'}

which will return this, (assuming a base URL of https://example.com/)

https://example.com/?css=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='channel/channel_css'}" />
<link rel="stylesheet" type="text/css" media="all" href="{stylesheet='template_group/css_template'}" />

which will return

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

- 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.
- 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.
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:

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

## 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 "channel_css" Template of the "channel" Template Group, you could point to it using the URL:
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:

[https://example.com/css/channel/channel_css](https://example.com/css/template_group/css_template)

[https://example.com/css/channel/channel_css/](https://example.com/css/channel/channel_css/)
- 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.
- This could also cause a conflict if you have a real folder named "/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](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.
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.

NO PARSING: `{stylesheet='template_group/css_template'}`

https://example.com/?css=template_group/css_template

FULL PARSING: `{path='template_group/css_template'}`

https://example.com/template_group/css_template