Part Two - The Basics

Templates - for basic HTML page structure


Usually a resource is assigned to a Template to provide the HTML structure for the completed page. MODX will process all of the MODX tags in the resource's template to generate the dynamic page that is returned to the user.

A resource assigned to the (empty) template will have its own content processed without a template. This is often useful in cases of AJAX processing, where the resource will only contain a snippet call to process the AJAX request. All of the MODX API and database access features are available, but there is no template to add unwanted HTML code to the returned string.

Since a resource can only be assigned to one Template, it is also a useful way of filtering resources so that you can get a collection of resources all assigned to a given template (or templates) for your purposes. One way that MODX itself filters resources by Template is when making Template Variable fields available to a resource during editing. Only resources assigned to specified Templates will have the TV fields.


Susan Ottwell
December 2015