Trongate Website Homepage

Understanding Templates

This chapter provides a comprehensive guide to understanding and working with templates in the Trongate framework.

What are Templates?

In Trongate, a template is a PHP file that generates a complete HTML web page. Templates serve as the structural foundation for rendering web pages, providing a consistent layout and design across your application.

Templates vs. Views

It's important to distinguish between templates and views in Trongate:

Where Templates Are Stored

Trongate organizes templates within a dedicated 'templates' directory, located in the root directory of your application.

Directory structure of the 'templates' module
The templates directory within a Trongate application

The Templates Directory: A Special Trongate Module

While the 'templates' directory is located at the root level of your Trongate application, it functions as a full-fledged Trongate module. This unique positioning allows for global accessibility while maintaining the familiar Trongate module structure.

Throughout this documentation, you may encounter the terms 'template module' and 'template directory'. These refer to the same entity: the 'templates' folder at the root of your Trongate application.

The 'templates' module adheres to the standard Trongate module structure, comprising:

This structure allows you to leverage Trongate's powerful module-based architecture for managing your application's templates, while ensuring they remain easily accessible to all parts of your application.