## Installation

Templating System

The templating system may be used alone or in conjunction with version 4.0 or greater of the ArsDigita Community System (ACS). The following instructions apply to a standalone installation only.

### Requirements

The templating system requires version 3.1 or greater of AOLserver for Unix or Windows. Until version 3.1 is officially released, you must use the ArsDigita distribution of AOLserver 3.0, which includes some required patches to the ADP parser. These patches have been integrated into AOLserver 3.1.

To use the database interface for merging dynamic data with your templates, you will also need to have installed any AOLserver-compatible RDBMS.

### Obtaining the distribution

To install the templating system, download and unpack the tar file under your page root:

    $ wget http://bob.sf.arsdigita.com:8089/ats/ats.tar.gz
    $ cd /web/myserver/www
    $ gunzip -c ats.tar.gz | tar xvf -

The distribution consists of four subdirectories:

1. `demo`: A set of sample templates and supporting files.
2. `doc`: Documentation and tutorials.
3. `tcl`: The Tcl module.
4. `resources`: Sitewide style templates for forms and error messages and associated assets.

You can also untar (or check out) the distribution somewhere else and symlink it under your page root. (If you do not wish to install the distribution under your page root, see the configuration options below).

### Installing the Tcl module

The templating system code is a Tcl-only module for AOLserver. For AOLserver to load the module source code, you must move, copy or symlink the `tcl` directory in the templating system distribution to the private Tcl library of your AOLserver installation (as indicated by the `Library` parameter in the `ns/server/myserver/tcl` section of the AOLserver configuration file):

    $ cd /web/myserver/tcl
    $ ln -s <path_to_distribution>/ats/tcl/ ats

### Configuring AOLserver

The last step is to modify your AOLserver configuration file. You will need to register the templating system as a Tcl-only module:

    [ns/server/myserver/modules]
    nssock=nssock.so
    nslog=nslog.so
    ats=Tcl

or if you are using the new configuration file format:

    ns_section "ns/server/${server}/modules"
    ns_param   nssock          nssock.so
    ns_param   nslog           nslog.so
    ns_param   ats          Tcl

Note that you should replace `ats` with whatever you named the directory or symlink for the templating code within your private Tcl library.

You will also need to ensure that the "fancy" ADP parser is the default:

    [ns/server/yourserver/adp]
    Map=/*.adp
    DefaultParser=fancy

    [ns/server/yourserver/adp/parsers]
    fancy=.adp

### Optional Configuration

The templating system recognizes two optional parameters in the AOLserver configuration file in the `ns/server/yourserver/ats` section:

`DatabaseInterface` | Specifies the set of procedures to use for accessing a relational database from the templating system. Two interfaces are supplied with the system: `oracle` (uses the `ns_ora` API in conjunction with the AOLserver Oracle driver) and `generic` (uses the `ns_db` API in conjunction with any AOLserver RDBMS driver). The default is `Oracle`.
`ShowCompiledTemplatesP` | Enables a filter on the `cmp` extension so that the compiled Tcl code for any template may be viewed in a browser for debugging purposes. The default is 0 (disabled).
`ShowDataDictionariesP` | Enables a filter on the `dat` extension so that documentation directives in Tcl scripts may be extracted and viewed in a browser. The default is 1 (enabled).
`ResourcePath` | Specifies the absolute path to the system `templates` directory, containing sitewide styles for forms, system messages, etc. Defaults to `$::acs::pageroot/ats/resources`.

### Testing the System

To test the system, run the script `demo/demo.sql` to create and populate a simple table in your database.

Save the configuration file and restart the server. Use the samples included in the distribution to test whether the system is working properly.