What Are Templates?
Although Trongate does not have a templating system (Trongate favours pure PHP), there is still a legitimate need to use and organise website templates - particularly for developers who are building medium to large scale apps. With this in mind, it might be worth taking a moment to clarify what is meant by the word 'template'.
In this instance, a 'template' is simply defined as being a file that contains some code that can be used to display an HTML web page.
How Is This Different From A View?
A view file can potentially contain an entire HTML template. We see examples of this on:
- the welcome.php file (stored inside the Welcome module)
- the error_404.php file (stored inside 'Templates/views/')
However, in most instances, an ordinary view file will contain HTML code that merely makes up part of an overall webpage.
Template files, on the other hand, will always contain enough code to generate a complete HTML page. Template files may call upon view files (and other kinds of files) to display full web pages - but this never goes the other way around. So, templates can load view files, however, view files never contain templates!
Templates are also designed to be reusable. In other words, they can be referenced and loaded in multiple different parts of a web app.
It's normal for a web app to have (for example) a public template that can be accessed by anyone and an admin template that can only be viewed by a site administrator who has logged in. Of course, the different templates for each of those different scenarios may potentially look completely different from each other.
Goals And Objectives
When it comes to the handling of page templates, the Trongate framework was built with the following goals and objectives:
- To be 'v1 forever'. In other words, learn once - use for a lifetime.
- To have a minimal amount of overheads. We want fast loading pages.
- To give developers a blank canvas upon which they can incorporate their own design or ideas that come from third party providers.
Just to quickly expand upon the last point:
- They take choice away from developers
- They encourage developers to build templates that all look and feel the same
- Furthermore, they leave developers at the mercy of an unknown third party provider's; rewrite schedule, bugs, hopes, fears, security flaws and bad days at the office!
Trongate's position, however, is unique because Trongate does not use any third party libraries whatsoever - leaving you the developer free to make your own decisions about how you'd like your pages to look and feel. Would you like to use some third party library with your web app? Great! Trongate won't get in your way. However, if you'd like to avoid using third party libraries then that's okay too.
Yet Another Reason For Choosing Trongate
It would have been all too easy to choose the easy path and declare,
"Trongate uses (insert name of third party library)"
In doing so, a great deal of work would have been passed off to somebody else and the Trongate framework would have been launched about six months earlier. But no! We did the right thing! Instead of choosing the easy path, we built our own libraries. All of them!
The Bottom Line
HELP & SUPPORT
If you have a question or a comment relating to anything you've see here, please goto the Help Bar.