Templates - Upgrading TNG 8.1

From TNG Wiki
Jump to: navigation, search
Ambox notice.png While this article covers upgrading templates in TNG V8.1, it also applies to current TNG versions when upgrading from a prior release where you copied your template to the TNG root folder
TNG 9.0
TNG 8.0


When upgrading to TNG V8.1 and above, you should copy the templates folders to your site, but you have a couple of options on how to upgrade your templates:

  • use the new Template Selection capability
  • stay at status quo
  • position for future

Template Selection

TNG V8.1 introduced the capability to select a template to be used in the Admin >> Setup >> Template Settings which was provided with TNG V8.

If you change the Enable Template Selection: from No to Yes, TNG V8.1 and above will use the files from the templates/templateN folders where the template used is indicated by the Template Number: selected.

If you use template selection (in 8.1.0 and above) and you choose one of the supplied templates, then TNG will use both the index.php in your TNG root path or main index.php file, which was provided in the special folder in the upgrade, *and* the index.php from your chosen template folder. Any call to your home page (index.php) will first load the index.php file that is in the main TNG folder. This script will "exit" and then load the index.php file for your template if it detects that a template has been chosen, and you have enabled Template Switching.

TNG V8.1 template selection.jpg

If you previously used the Template Settings options in TNG V8 to tailor your home page, potentially without having to modify any code in the template index.php file, you should probably use the new Enable Template Selection capability.

Rename your existing index.php file in your TNG root path and then copy the index.php file from the special folder to your TNG root. Or you could also use the approach shown in the Position for Future section below, and copy the required lines of code into your current index.php page as shown. This will allow you to switch back to your index.php page at any future time simply by setting "Enable Template Selection" to NO.

Maintain Status Quo

If you have been using TNG for several years and have your own template file, the way you want it, you should probably use the status quo approach, and not copy the index.php from the special folder.

Note that in TNG V8.1 and above if you leave the Enable Template Selection set to No and the Template Number blank, then TNG continues to use the template files from the TNG root folder, whether that be a template you copied from the templates folder, the default TNG template, or one you created yourself.
TNG V8.1 template selection status quo.jpg

According to Darrin's TNG 8.1.0 announcement email, you should also be able to still use the Template Number to configure your existing conditions. However, this requires that you previously copied the template files to the TNG root folder, and may require that you update the index.php according to the upgrade readmexxx-810.html instructions. Note that I have not tested this approach. --Ken Roy 13:24, 5 January 2011 (UTC)

You may however want to position for the future, as shown below.

Position for Future

To position for a future use of the Template Selection and Template Settings capability, you should modify your existing index.php file in the TNG root path which then becomes your main index.php, by adding the following lines to your index.php file.

The index.php file provided in the special folder as part of the upgrade contains several lines, that you should insert in your current index.php file, immediately after the db connection and checklogin.php lines


tng_db_connect($database_host,$database_name,$database_username,$database_password) or exit;
include($cms['tngpath'] . "checklogin.php");

and/or immediately before the line

$flags['noicons'] = true;

These are the lines to insert into your index.php file in the TNG root folder:

//Insert the following lines in your index.php to take advantage of template switching
if($templateswitching && $templatenum) {
        include($cms['tngpath'] . "templates/template$templatenum/index.php");
        exit;
}
//end of lines to be inserted for template switching

Related Links

See Templates - Getting Started for additional information on how to select and use templates.

See Template Settings for information on tailoring your template.

See Template Settings - V8.1 Fixes for a TNG mod that replaces hard-coded English text and headings in Templates 4, 5, 6, and 8

See Template Settings - V9