Magic Smoke Template Design

logo
The web user interface is constructed with templates with just a few dynamic values filled in. Those templates are found in the template/* directories. These templates are normal HTML or text with some special constructs to fill in the blanks.

Please see the Twig template engine documentation for syntax details.

Template Files

There are template files for everything that is displayed on the web page and for all types of eMail sent by the MagicSmoke customer system.

Each of the example templates contains some hints what data is available. Most objects are types from the Web Object Interface.

Please see the Templates Chapter of the PHP Source Documentation.

Template Caching

The Twig template engine compiles the templates into PHP code before actually displaying anything. You have the choice to discard those compiled templates or to store them for faster access next time the page is called.

Allowing the web server write access to a directory opens a potential security hole. If you want to do caching more securely:

  1. create a storage directory in parallel to the template directory, eg. tcache, or if it already exists empty it
  2. make sure the directory is writable by the web server
  3. enter this directory into the Twig configuration:
    $twigoptions=array( 'cache' => './tcache' /*...*/ );
  4. uncomment the "setAdminPassCode" line in config.php
  5. open index.php?mode=compile in a browser - it will ask you to enter the admin credentials
  6. the page will compile all templates it can find and store them in the configured cache directory
  7. restrict the directory access rights so the web server cannot write to it any more, make sure it can also not overwrite the files inside the directory
  8. comment out the "setAdminPassCode" line in config.php