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:
An increasing assortment of PHP frameworks have been tethered to third party CSS libraries and/or JavaScript libraries. For example, the Yii2 framework has been tethered to an old version of Bootstrap for several years and it has caused that community huge problems. More recently, Laravel appears to in the midst of some sort of alignment or association with Tailwind - another third party CSS library. These types of associations - when they happen - never turn out well. That's because:
- 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!
To be clear, there's nothing fundamentally wrong with using third party CSS libraries or JavaScript libraries. Some of them are great. Use them. Enjoy them!
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
Trongate comes with its own set of JavaScript and CSS libraries. We have; date pickers, time pickers, date range pickers, date and time pickers, time range pickers, single file uploaders, 'drag and drop' multi file uploaders, a powerful API manager, plus a CSS library that's arguably the best in the entire industry!
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
When it comes to designing beautiful, interactive pages - Trongate has you covered. It's the only PHP framework that gives you everything you need - straight out of the box! Having our own CSS and JavaScript libraries means that Trongate developers never have to worry about rewrite culture. Nevertheless, for developers who want to use other code - be it CSS, JavaScript or something else - then that's okay too. Trongate can be your perfect blank canvas. When it comes to designing templates, Trongate puts you in the driving seat.