ExpressionEngine

2.11.7 User Guide

Legacy Documentation

You are using the documentation for version 2.11.7. Go here for the latest version or check here for your available upgrades to ExpressionEngine 3.

The Template Engine

At a basic level, Templates contain almost everything you want displayed on the front-end of the site. When ExpressionEngine serves up each Template, the system must go through a rendering process to parse out the Tags, Variables, Snippets, and Embeds being used in the Template.

Note

The information in this article applies only to rendering Templates. It doesn’t apply to rendering theme files such as those used for Member Profiles, the Wiki module, or the Discussion Forum module.

ExpressionEngine goes through several stages to fully process each Template, and this article exposes the order of those rendering stages. Understanding how the system renders a template can help immensely when building pages and troubleshooting problems.

Note

As of 2.9.0 conditional tags evaluate when ready.

Rendering Stages

The Template Engine processes the selected template fully from top to bottom through each rendering stage.

  1. Determine template to process based on request URI
  2. Get template from database, check template access permissions, and increment the hit counter
  3. If it exists, get template from file
  4. If template type is static, return template and end parsing
  5. Parse (as a group, so order is irrelevant):
  6. Parse segment variables
  7. Parse embed variables
  8. Parse layout variables
  9. Parse date formatting string constants
  10. Parse {template_edit_date}
  11. Parse {current_time}
  12. If present, get cached template, then skip to the advanced conditionals parsing stage
  13. Parse PHP on Input
  14. Parse conditional tags
  15. Assign and parse preload_replace variables
  16. Parse module and plugin tags
  17. Parse PHP on Output
  18. Write template to cache file
  19. Parse conditional tags
  20. Process template layouts
  21. Process embedded templates
  22. Process redirect variable
  23. Parse user-defined global variables
  24. Parse some standard global variables (separately, in order given):
    • {hits}
    • {ip_address}
    • {ip_hostname}
    • {homepage}
    • {cp_url}
    • {site_name}
    • {site_url}
    • {site_index}
    • {webmaster_email}
    • {stylesheet}
    • {encode}
    • {debug_mode}
    • {gzip_mode}
    • {app_version}
    • {version}
    • {app_build}
    • {build}
    • {charset}
    • {lang}
    • {doc_url}
    • {password_max_length}
    • {theme_folder_url}
    • {member_profile_link}
    • {captcha}
  25. Add CSRF tokens to forms and parse {csrf_token}
  26. Parse remaining standard global variables (separately, in order given):
    • {member_id}
    • {group_id}
    • {group_description}
    • {group_title}
    • {member_group}
    • {username}
    • {screen_name}
    • {email}
    • {ip_address}
    • {location}
    • {total_entries}
    • {total_comments}
    • {private_messages}
    • {total_forum_posts}
    • {total_forum_topics}
    • {total_forum_replies}
  27. Parse alternative syntax forms of the member variables above
  28. Parse path variables (including {route=...} paths)