Mig - Templates

Page layout is handled using template files wherever possible.

About Tags

Template files are simply HTML files with special tags embedded in them. Mig expands these tags at runtime.

Tags are surrounded by %% marks, such as this example:

<title>%%pageTitle%%</title>

In this case, “pageTitle” is the relevant tag name.

There is a glossary of tags later in this document.

If you don’t know anything about HTML you can try checking out htmlhelp.com or looking for some other online help sites by using a search engine such as Google.

Make backups of template files before modifying them in case things don’t work out as expected.

Including Files

An “include” function is provided. To include a file, place a directive like this one on a line by itself:

#include "filename";

Such as:

#include "custom.html";

The contents of the specified file will be inserted in place of the #include placeholder.

If the file mentioned by #include is a CGI file then it will be executed, and its output will be placed there instead. NOTE: CGI can only be used with Apache servers (and not even every installation of Apache will do this correctly). Sorry, it’s a limitation in PHP that I can’t work around.

If including a CGI make sure it prints appropriate HTTP headers before anything else (just like any other situation where CGI is used).

Please note some things about #include:

  1. Included files must be located in the templates directory.

  2. If that’s undesirable, a symbolic link will also work. For example:

     ln -s /www/htdocs/includes/custom.html /www/htdocs/mig/templates

    This would create a symbolic link /www/htdocs/mig/templates/custom.html which would point to the real file /www/htdocs/includes/custom.html. Thus, there’s only one copy to maintain.

  3. The #include directive must be on a line by itself. It will not function if anything else is on that line. Also, the filename must be in quotation marks, and the command must be terminated with a semicolon. Here are some examples:

     #include "custom.html";           # RIGHT
     #include "custom.html"            # WRONG - no semicolon
     #include custom.html;             # WRONG - no quotes
     <p>#include "custom.html";</p>    # WRONG - not alone on line
  4. As of version 1.2.5 it is possible to include PHP files as well as other types of files. The one difference is that for PHP files the filename must have an extension of either “.php” or “.php3”.

Special Files

There are three special files that Mig uses for its own purposes.

Defined Tags

The following is a glossary of recognized Mig template tags, and what they are expanded to.

  1. Tags for use in any template
  2. Tags used only in folder.html (or mig_folder.php in Portal mode)
  3. Tags used only in image.html (or mig_image.php in Portal mode)

Custom Per-folder Templates

If desired, one can define a per-folder template file. This can be done with the FolderTemplate entity, as discussed in the “mig_cf” document.

Managing Colors

Mig uses a Cascading Style Sheet (CSS) file to manage all of its element colorization. Things like the page background, background colors for table cells, all are managed by the CSS file templates/style.css.

I don’t have the inclination or time to write a tutorial on how CSS works, so please see http://www.htmlhelp.com/reference/css/ or whatever else you come across to figure out how CSS works. There are some books on this topic available as well (try searching for “CSS” at Amazon.com). A basic example follows, though.

To change background color of description tables from #f0f0f0 (grey) to #FF0000 (red):

Before:
    TD.desc {
        color: #333333;          padding-top: 4px;
        background: #f0f0f0;     padding-bottom: 3px;
        font-size: .9em;         padding-left: 4px;
        text-align: center;      padding-right: 6px;
    }

After:
    TD.desc {
        color: #333333;          padding-top: 4px;
        background: #ff0000;     padding-bottom: 3px;
        font-size: .9em;         padding-left: 4px;
        text-align: center;      padding-right: 6px;
    }

In this example, only the third line (background) was changed.