ExpressionEngine® User Guide

Preload Text Replacements

ExpressionEngine allows you to assign text to be replaced prior to a template being parsed, to save time typing and editing certain bits of text that might get used multiple times. Preload Replacements act as a straight string replacement for use later in the same template.

Assignment and replacement occurs instantly when the template is loaded, before any tags are parsed, and therefore may not be affected by the result of another tag’s output.

Creating and Using an Preload Replacements

The basic syntax for replacing text is this:


In the above example, variable_name is the name of the template “variable” and replacement is the content that will be used to replace all occurrences of {variable_name} in the template.

Example Usage

A common usage for preload replacements is to hold the Channel short name(s), to save you from repeatedly typing them into different tags within the same template.


{exp:channel:category_heading channel="{channels}"}
        {if category_description != ""}<p>{category_description}</p>{/if}

{exp:channel:entries channel="{channels}" limit="10"}

User Contributed Notes

Posted by: GDmac - expocom on 2 January 2012 3:16pm
GDmac - expocom's avatar

... Assignment and replacement occurs instantly when the template is loaded, before any tags are parsed…
If you assign a value to the same preload variable multiple times, then only the first declaration will be used.
The tag is, as mentioned, instantly replaced, leaving no other tag with the same name in the template to be replaced by a second declaration.

However, (hat-tip to Lodewijk), because of parse order, there are some tags that are parsed before preload_replace:
these are snippets, segment_x, embed:var variables and simple conditionals, and global_vars declared in index.php,  which we can use to our benefit (tested with EE 2.3.1). e.g.

// simple conditionals allow you to override a preload var if a segment is set, remember, only the first preload in a template is used
{if segment_3 != ""}{preload_replace:foo="special"}{/if}

// current_time is also parsed early, So you can use ee-tags, but always be careful to surround single quotes with double quotes!
{preload_replace:party="Welcome to the {current_time format='%Y'} pages"


Posted by: e-man on 24 November 2011 2:06pm
e-man's avatar

An excellent article on taking snippets and preload replace vars a step further by codemeister @low can be found here:

Posted by: Chad Crowell on 22 June 2010 3:48am
Chad Crowell's avatar

Updated RSS 2.0 template for EE2 using a channel called Blog and related links in the body. Adapt as needed for your channel

:rss:feed channel="{master_channel_name}"}

<?xml version
="1.0" encoding="{encoding}"?>
<rss version="2.0"

dc:rights>Copyright {gmt_date format="%Y"}</dc:rights>
dc:date>{gmt_date format="%Y-%m-%dT%H:%i:%s%Q"}</dc:date>
admin:generatorAgent rdf:resource="" />
{exp:channel:entries channel="{master_channel_name}" limit="10" rdf="off" dynamic_start="on" disable="member_data|trackbacks"}
guid>{site_url}/blog/view/{url_title}#When:{gmt_entry_date format="%H:%i:%sZ"}</guid>
dc:subject>{exp:xml_encode}{categories backspace="1"}{category_name}{/categories}{/exp:xml_encode}</dc:subject>
dc:date>{gmt_entry_date format="%Y-%m-%dT%H:%i:%s%Q"}</dc:date>


You must have an EllisLab product license and have at least 50 posts to the community forums to contribute notes to the User Guide