Introducing the Smarty Template Engine


Note: This is the first in a three part series leading up to the release of PacerCMS 0.5. You can start building for the upcoming version by downloading our preview release.

It is a simple concept, but often overlooked in content management systems. Consider the possibility that programmers have only a passing interest in design, while designers only have a passing interest in programming. If this were true, then why would you force them to share the same file when it comes to changing the look and feel of your Web site?

Enter the template engine

Article Template

The article template, less the sidebar, is only 18 lines of code. No PHP needed.

Version 0.5 of PacerCMS now includes the Smarty Template Engine, an easy to use and even easier to understand template engine that helps separate your programming logic from the design process. Using only a few bracketed variables, you can break "out of the box" a bit without having to learn PHP. Intrepid programmers looking to add that "something extra" to the system can easily hook into the underlying framework to do some pretty amazing stuff without worrying a great deal about the presentation.

Here is how to get started, provided you have already successfully installed PacerCMS.

  1. Copy the files in your ./templates/default/ directory into the ./templates/local/ folder. This serves two purposes. One, to have a working model to modify to your liking without starting from scratch. Two, you have a backup to quickly refer to if something appears broken.
  2. Modify your ./includes/config.php to point to the "local" folder instead of the "default" one. You might catch on that you can create your own folder in the ./templates/ directory as long as the configuration file can find it.
  3. While you are in there, you might want to turn on debugging by setting DEBUG_MODE to "true". This tells Smarty to render a pop-up window every time the page is reloaded to show you exactly what it is grabbing from the PHP scripts. This would be disabled again on the production Web site.
  4. Take a look inside the "local" folder. The header.tpl,foot.tpl and sidebar.tpl files are handy for your re-usable page elements (like the header, footer, and sidebar of course). All are called using the simple {include file="file.tpl"} tag.

To learn more about Smarty, visit their Web site. Remember, to use this feature you will need version 0.5 or higher. Have a question about using the new template engine? Just shoot an e-mail to our developer community and we will be happy to assist.