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
In addition to HTML and other markup, templates usually contain [ExpressionEngine Tags](templates/language.md), which allows information to be served dynamically.
37
37
38
-
## Creating a Template
38
+
## Creating & Editing Templates
39
39
40
40
Templates can be created and edited in the `Developer -> Templates` area of your Control Panel.
41
41
42
-
ExpressionEngine, by default, saves Template Groups, Templates, Global Variable, and Template Partials as regular folders and files on your server at `system/user/templates`. This allows you to use your preferred text editor to edit Templates and then FTP the changes to the server.
42
+

43
+
44
+
You start off by creating a template group. During creation you will have the option to duplicate an existing group with all of its templates. You can also select the roles that will have editing permissions for templates in this group.
45
+
46
+
Then, create individual templates. You can duplicate an existing template, or create a blank one. If necessary, change the template type from "Webpage" to the type that you need (RSS Page, CSS, JavaScript, Static, XML)
47
+
48
+
Existing templates can be edited with the built-in editor, which provides intelligent syntax highlighting.
49
+
50
+
TIP: **Tip:** The font size in the template editor can be adjusted with a [configuration override](general/system-configuration-overrides.md#codemirror_fontsize).
51
+
52
+
You can also edit template preferences and set front-end access permissions for the template.
53
+
54
+

55
+
56
+
## Saving templates as files
57
+
58
+
Template Groups, Templates, Global Variables, and Template Partials are always saved into the database and this is their primary source, however by default they are also saved as regular folders and files on your server.
59
+
60
+
This behavior is controlled by [system configuration overrides](general/system-configuration-overrides.md#save_tmpl_files)in `system/user/config/config.php`:
61
+
```php
62
+
// Controls whether template and partial files should be saved on filesystem
63
+
$config['save_tmpl_files'] = 'y';
64
+
// Controls whether Global variables should be saved as files (requires `save_tmpl_files` also being set to `y`)
65
+
$config['save_tmpl_globals'] = 'y';
66
+
```
67
+
68
+
The directory structure would be similar to what is shown below:
69
+
70
+
```
71
+
|-- system
72
+
| |-- user
73
+
| | |-- templates
74
+
| | | |-- _global_partials
75
+
| | | | |-- _header.html
76
+
| | | | |-- _footer.html
77
+
| | | |-- _global_variables
78
+
| | | | |-- logo.html
79
+
| | | |-- default_site
80
+
| | | | |-- _partials
81
+
| | | | | |-- sidebar.html
82
+
| | | | |-- _variables
83
+
| | | | | |-- address.html
84
+
| | | | |-- blog.group
85
+
| | | | | |-- entry.html
86
+
| | | | | |-- feed.xml
87
+
| | | | | |-- index.html
88
+
| | | | |-- home.group
89
+
| | | | | |-- contact.html
90
+
| | | | | |-- about.html
91
+
| | | | | |-- index.html
92
+
| | | | |-- styles.group
93
+
| | | | | |-- contact.css
94
+
| | | | | |-- index.css
95
+
| | | |-- second_msm_site
96
+
| | | | |-- _partials
97
+
| | | | | |-- sidebar.html
98
+
| | | | |-- _variables
99
+
| | | | | |-- address.html
100
+
| | | | |-- home.group
101
+
| | | | | |-- about.html
102
+
| | | | | |-- index.html
103
+
```
104
+
105
+
This allows you to use your preferred text editor to edit Templates and then transfer the changes to the server.
106
+
107
+
`default_site` and `second_msm_site` are the site short names if you're running [Multiple Site Manager](msm/overview.md). If you have just one site, `default_site` is going to be the only one you need.
108
+
109
+
`_partials` folder holds your [template partials](templates/partials.md) for the site, and `_global_partials` holds partials that are shared through all MSM sites.
110
+
111
+
`_variables` folder holds your [template variables](templates/variable.md) for the site, and `_global_variables` holds variables that are shared through all MSM sites.
43
112
44
113
These are the naming rules that ExpressionEngine applies to these resources:
45
114
@@ -52,7 +121,11 @@ These are the naming rules that ExpressionEngine applies to these resources:
52
121
-_.xml_ creates an 'xml' template type
53
122
- Template group names (not including the .group) and template names (not including the .extension) are limited to 50 characters. Anything longer than that will be truncated by the database and fail to match the file.
54
123
55
-
You can also choose to save templates in the database using this [system configuration override](general/system-configuration-overrides.md#save_tmpl_files).
124
+
Having several templates with the same name but different extensions is not supported.
125
+
126
+
The existing templates are synchronized with the files as soon as any site page is accessed. If you created a new template or a new template group on the file system, the pages or edits will be immediately available, though they will not be added to the database until you visit the `Developer -> Templates` section of the Control Panel or the template is visited on the frontend.
127
+
128
+
NOTE: **Note:** When saving templates as files, `index.html` will be placed automatically into each template group folder when the templates are synchronized.
56
129
57
130
## Hidden Templates
58
131
@@ -85,7 +158,7 @@ Additionally, PHP code in templates will operate slower than same code wrapped i
85
158
86
159
ExpressionEngine allows you to place [PHP](https://www.php.net/) code within your Templates so that it can be executed, allowing more dynamic capability with your content.
87
160
88
-
In order for this feature to be available, it needs to be enabled by adding
161
+
In order for this feature to be available, it needs to be enabled by adding
0 commit comments