Flat File Templates / Theme System
Posted: Sat Dec 03, 2016 8:54 am
I started using CMS Made Simple in 2006 and I can remember when the decision was made to move the templates from flat files into the DB. At the time it didn't seem like that big of a deal and in fact was probably the right decision given the mission of the project which was to make a simple cms that was accessible to a wide range of users.
In a lot of ways CMSMS was ahead of it's time. From the beginning the platform implemented OOP and auto loading which was a sharp contrast from the procedural PHP code that was being implemented in projects like WordPress and Drupal.
In addition, CMSMS separated the presentation layer from the logic and even implemented a templating language called Smarty. It's important to put this into context because at the time languages like Twig, Blade, Handlebars and Mustache were not in wide use or didn't even exist. Kudos to the creators of CMSMS for having this foresight.
As time past and more and more CMS's stared to use templating engines and the popularity of VCS such as Git grew, CMSMS continued to keep the templates in the DB.
In my humble opinion, this has been a major misstep of the project.
Major improvement were made with the template system with CMSMS 2.0 but one thing that is still lacking is the ability to move templates out of the DB and into flat files.
I believe that CMSMS would be a lot more attractive to developers if the templates are stored as flat files rather than in the DB. Smarty is powerful and is actually faster than Twig. Much of the work required to setup a CMSMS site is done in Smarty templates. Therefore, I think it makes sense to be able to store the template files as flat files and commit them to a repository. This also supports a modern workflow of making changes in a editor of your choice and committing them to a repository.
I like the way Drupal handles the relationship between what's in the code and what's in the DB and I think that CMSMS could benefit from using the same model. If a change has been made in the DB, Drupal simply denotes that the template is overwritten, meaning that the DB has a different version of that file. It's up to the user to revert the template to the file version or to continue to use the DB version.
How hard would it be to implement this change to the core? Is there a way this could be implemented using the API?
In a lot of ways CMSMS was ahead of it's time. From the beginning the platform implemented OOP and auto loading which was a sharp contrast from the procedural PHP code that was being implemented in projects like WordPress and Drupal.
In addition, CMSMS separated the presentation layer from the logic and even implemented a templating language called Smarty. It's important to put this into context because at the time languages like Twig, Blade, Handlebars and Mustache were not in wide use or didn't even exist. Kudos to the creators of CMSMS for having this foresight.
As time past and more and more CMS's stared to use templating engines and the popularity of VCS such as Git grew, CMSMS continued to keep the templates in the DB.
In my humble opinion, this has been a major misstep of the project.
Major improvement were made with the template system with CMSMS 2.0 but one thing that is still lacking is the ability to move templates out of the DB and into flat files.
I believe that CMSMS would be a lot more attractive to developers if the templates are stored as flat files rather than in the DB. Smarty is powerful and is actually faster than Twig. Much of the work required to setup a CMSMS site is done in Smarty templates. Therefore, I think it makes sense to be able to store the template files as flat files and commit them to a repository. This also supports a modern workflow of making changes in a editor of your choice and committing them to a repository.
I like the way Drupal handles the relationship between what's in the code and what's in the DB and I think that CMSMS could benefit from using the same model. If a change has been made in the DB, Drupal simply denotes that the template is overwritten, meaning that the DB has a different version of that file. It's up to the user to revert the template to the file version or to continue to use the DB version.
How hard would it be to implement this change to the core? Is there a way this could be implemented using the API?