ExpressionEngine Docs

# Template Manager

Control Panel Location: `Developer > Templates`

- Create Template
- Edit Template
- Template Routes
- Email Templates
- Forum Templates
- Member Profile Templates
- System Message Templates
- Template Partials
- Template Variables
- Create/Edit Template Group

The Template Manager allows you to create, edit and delete Template Groups and Templates. Clicking a particular Template Group name will reveal that Group so that you can work with it.

## Create Template

Control Panel Location: `Developer > Templates > Create New Template`

This section of the Control Panel allows you to create a new template within a template group.

New template settings:

- Name – The name of the Template. This must be a single word with no spaces. You may use the letters a-z, the numbers 0-9, and the underscore and hyphen/dash characters. You should refrain from creating all-numeric Template names as they can cause confusion with Entry IDs used in URLs.
- Type – Here you may specify the type of Template:
  - Webpage: This is the most common type of Template. Unless you specifically need one of the other two types you should use this one.
  - CSS: This type is used for Stylesheets. It tells ExpressionEngine to serve the Template as “text/css” MIME type. Further, the Template will not be parsed for EE Tags like normal. The Template is served “as-is”.
  - RSS Page: Used for RSS and Atom syndication feeds. It tells ExpressionEngine to serve the Template as “text/xml” MIME type.
  - JavaScript: Used for outputting JavaScript code. It tells ExpressionEngine to send “text/javascript” MIME type server headers when being viewed.
  - Static: Used for static content with absolutely no ExpressionEngine rendered tags. Useful for HTML design elements embedded in other templates.
  - XML: Used for outputting XML pages with EE. It tells ExpressionEngine to send “text/xml” MIME type server headers when being viewed.
- Duplicate existing template? – You may choose one of your existing Templates to duplicate its contents.

## Edit Template

Control Panel Location: `Developer > Templates > Edit`

This section of the Control Panel allows you to edit a templates contents and settings.

This page has the following tabs:

- Edit
- Notes
- Settings
- Access

### Edit

The content of the Template.

### Notes

The Template Notes tab enables you to save notes and information about your template. This information is available only in this page.

### Settings

- Template Name – The name of the Template. This must be a single word with no spaces. You may use the letters a-z, the numbers 0-9, and the underscore and hyphen/dash characters. You should refrain from creating all-numeric Template names as they can cause confusion with Entry IDs used in URLs.
- Type – Here you may specify the type of Template:
  - Webpage: This is the most common type of Template. Unless you specifically need one of the other two types you should use this one.
  - CSS: This type is used for Stylesheets. It tells ExpressionEngine to serve the Template as “text/css” MIME type. Further, the Template will not be parsed for EE Tags like normal. The Template is served “as-is”.
  - RSS Page: Used for RSS and Atom syndication feeds. It tells ExpressionEngine to serve the Template as “text/xml” MIME type.
  - JavaScript: Used for outputting JavaScript code. It tells ExpressionEngine to send “text/javascript” MIME type server headers when being viewed.
  - Static: Used for static content with absolutely no ExpressionEngine rendered tags. Useful for HTML design elements embedded in other templates.
  - XML: Used for outputting XML pages with EE. It tells ExpressionEngine to send “text/xml” MIME type server headers when being viewed.
- Enable Caching? – This determines whether or not Template Caching is enabled for the Template. This is used together with the following preference.
- Refresh Interval – If the previous preference is enabled, then this specifies how long (in minutes) the Template cache should active. The next time the Template is requested after the time interval has expired, a new cache will be created.
- Allow PHP? – Here you specify whether or not the Template will parse PHP expressions. If the preference is set to “no”, then any PHP in the Template will be output as plain text.
- PHP Parsing Stage – If the previous preference is enabled, this sets whether PHP is parsed on “input” or “output” in the Template. See Using PHP in Templates for more information.
- Hit Counter – If you wish to manually revise the hit counter for a Template you may do so.

### Access

- Allowed member groups – Choose which member groups are allowed to access the template.
- No access redirect – Page to redirect users without permissions to. If a template is selected the user does not have access to, the 404 page will be displayed instead.
- Enable HTTP Authentication? – When set to enable, users with permissions will have to login to view this template.

Note: If you are running PHP-FPM / FastCGI, you will probably need to add this to your `.htaccess` so the server makes the necessary environment variables available to PHP & ExpressionEngine.

    SetEnvIf Authorization "(.*)" HTTP_AUTHORIZATION=$1

or:

    RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]

- Template route override – Overrides the ExpressionEngine standard group/template routing.
- Require all segments? – When set to yes, all segments must be present in the request URI.

## Template Routes

Control Panel Location: `Developer > Templates > Template Routes`

The Template Route Manager shows all templates that are assigned a template route and allows you to add, edit and manage your Template Routes.

Routes are listed in the order that the Template Router will match your templates.

Routes have the following settings:

- Template – The template to apply the route to.

- Route – This route determines the URLs that will match your template. For more info see: Template Routes

         /segment/{variable}/{variable:rule}/{variable:rule0|rule1[arg]}

- Require all Segments? If set to “yes” all segments defined in your Template Route must be contained in a URL in order for it to match. If set to “no” and static variables are used in the route, all variables will still be required in order for the URL to match the route. For example, `/add/{url_title:alpha_dash}` will not match the URL /add. It requires a third segment to match. In order to use static variables and not require all variables, use a regular expression match in place of a static variable. In the example above, replace the static variable `add` with a regular expression match. The resulting route would look like:

        /{seg1:regex[(add)]}/{url_title:alpha_dash}

## Email Templates

Control Panel Location: `Developer > Templates > Email`

This section of the Control Panel is for the various “notification” emails that are sent by the system. For example, when someone registers at your site, account activation instructions are emailed to them. The formatting of the email is controlled in one of the Message Pages.

## Forum Templates

Control Panel Location: `Developer > Templates > Forums`

The ExpressionEngine Forums make use of “themes” to determine how they are displayed. The Forum Module comes with a “default” theme, which is located in your installation under themes/forum_themes/.

In order to edit the Templates inside the Control Panel, set the theme folders and files to be writable. See File Permissions for details.

If you plan to make changes to your theme, we recommend that you make a copy of the themes/forum_themes/default/ directory, name it something else, and make your changes to that one. You can easily switch themes simply by choosing a new one under Default Preferences.

For anyone creating their own theme or modifying one, the original “PSD” version of the “ExpressionEngine Forums” graphic is available for download.

## Member Profile Templates

Control Panel Location: `Developer > Templates > Members`

The public profile area has its own set of templates which can be edited to change the look. You’ll find the templates located at:

    themes/ee/member/default/

A good strategy is to make a copy of the entire default templates folder, then edit your copy so you can leave the default files intact. Save your new copy to:

    themes/user/member/custom_theme_name/

You can set your new copy as the site default under `Settings --> Members`

Note: When building your member profile templates, consider that any external links will pass along referrer data. This can cause security problems if someone clicks on an external link from a secure page. For example, if a user clicks an external link from the password reset page, the external site could use the password reset link from the referrer data to gain access to a user’s account.

You can strip everything but the base URL by linking to `{path=""}?URL=<your url>`.

## System Message Templates

Control Panel Location: `Developer > Templates > Messages`

This section of the Control Panel is for managing the system message templates, such as the Site Offline template and the User Messages template.

In the General Settings section of the Control Panel you can specify whether or not your site is “Live”. If the site is not live then people will be presented with a message when they try to access your page. This can be useful if you are performing maintenance or other such things. This Message Page allows you to define the page that will be shown to people when your site is not “Live”.

Users often receive messages after performing actions in ExpressionEngine: logging in, submitting a form, etc. In addition, they may sometimes be shown error messages. You can determine how the page looks that displays these messages.

## Template Partials

Control Panel Location: `Developer > Templates > Template Partials`

In this section of the Control Panel you can create and edit Template Partials.

## Template Variables

Control Panel Location: `Developer > Templates > Template Variables`

In this section of the Control Panel you can define custom data that you would like to be available globally in any Template. This is in addition to the standard Global Template Variables that are already available.

You could create a Global Variable for any number of purposes. One idea would be for a piece of copyright text that would be included on every page. By making it a Global Variable you can change it in one place and immediately see the effects everywhere.

Global Variables can contain text, HTML, javascript, etc. but cannot contain PHP code or ExpressionEngine tags that you wish to have parsed.

## Create/Edit Template Group

Control Panel Location: `Developer > Templates > New/Edit`

This section of the Control Panel allows you to create or edit a template group.