Creating a new Template - TNG V12

From TNG_Wiki
Jump to navigation Jump to search
Ambox notice.png The Creating a new Template - TNG V12 may not be not complete. If you find errors or missing information in the instructions, please make the appropriate corrections and additions.
Creating a new template may not protect you entirely from TNG changes to templates. For example, TNG V10 adds mobile device support which you will need to add to the template you created in TNG V9 in order to order to provide the new Mobile Mode Display to your visitors and TNG v12 also moved the Template Settings to a database table
TNG 12.0


The easiest way to create a new template in TNG V12 and above might still be to create a copy of an existing TNG template. However since the template settings are no longer maintained in templateconfig.php but are now in the tng_template table, you need to

  • use the Template Manager mod to unload the template you want to clone,
  • copy the _templateconfig.php file that was unloaded to your new template folder
  • open the _templateconfig.php file in Notepad++
  • replace the template number for the unloaded template with that of your new template
  • use the Template Manager mod to load the new template to the TNG Templates (tng_templates) table

For example, if you want to create your own version of Template 4 and call it Template 40 that would be maintained using the TNG Template Settings, you need to do the following:

  • create a new template subfolder, say template40
  • copy the TNG templates/template4 folder and all its subfolders contents
  • paste the copied folders and files into the template40 folder
  • unload the variables for Template 4 using the Template Manager
  • copy the unload _templateconfig.php file from the Template4 folder
  • paste the copied file to your new Template40 folder
  • open the _templateconfig.php file using Notepad++ or other appropriate ASCII text editor
  • replace all the appropriate text variables for your new template variables (for example $tmp['4_ with $tmp[ 40_
  • upload the updated _templateconfig.php for your new template (Template 40 in this example)
  • update the admin_templateconfig.php if needed
  • update the index.php and topmenu.php files, replacing all occurrences of copied template number with the new template number, for example if you copied template4 and created template40, the all occurrences of t4_ would be changed to 't40_' in the template40 folder

Copy Template Folder

When you create a copy of an existing template folder and add that new folder to the templates folder structure, TNG immediately starts showing that Template as available in the Template Settings.

For example, if you created a copy of the template4 folder structure and called it template40 and then added the template40 folders to the templates folder structure, Template 40 will then show in the list of templates.

Note that selecting Template 40 at this point will not show any Template Settings, because none have been added to the tng_template table yet.

Template folder with no tng_template entries

Copy of Template Variables

In order to add the Template Settings capability for your new template, you must

  • unload the variables that are for the template you chose to copy using the Template Manager
  • copy the unloaded _templateconfig.php file from the unloaded template folder
  • paste the copied _templateconfig.php file to your new template folder
  • open the copied _templateconfig.php file with Notepad++ or other appropriate ASCII editor
  • replace the variables in the copied _templateconfig.php file
for example if you copied template4 and created a template40, you would change the copied $tmp['4_... variables to $tmp['40_...
  • upload the replaced _templateconfig.php from your new template folder using the Template Manager

the new template variables will now show in the Template Settings


If you are going to add new variables, then you will need to create $text variables in your cust_text.php file for the new Template Settings labels, if they do not exist for another template.

Note that the variables used in the admin_templateconfig.php are not specifically tied to a template number, so you can reuse a template variable from another template.

New Template Variables

When you create new template variables that are not defined for another template, you need to make changes in more than one location:

  • _templateconfig.php that you will load using the Template Manager for the new variable
  • cust_text.php for the $admtext label
  • admin_templateconfig.php to add the variable to the
    • textarea array for those variables where you want more than one input line
    • translation array for those variables to be displayed in the language specific Home page

If you are going to add new template variables that get added to the textarea and / or translation array then you should create a Mod Manager config file to track your changes and be able to apply them to new TNG versions and upgrade releases

Template Settings Labels

When you create a new variable for a template, you will need to create a $admtext label for that variable. It should not include the template number portion, for example the 40_ of the Template Manager _templateconfig.php file variable. TNG will use the same variable for multiple templates.

Note that a label is only needed if it does not already exist for another template. If you were to add Mom's Side capability to Template 40, for example, a new $admtext variable is not needed since one already exists for Templates 8, 9, 10, and 11.

Multi-language

If your new Template Settings label will be used for more than one language, then you will need to modify the translation ($needtrans) array in the admin_templateconfig.php to add your new variable.

In order to use your new multi-language variable within the index.php or topmenu.php file, you will need to use the getTemplateMessage function to display the correct language version of the variable content.

Changes to the admin_templateconfig.php file should preferable be made using the TNG Mod Manager.

Textarea

If your new variable is for a textarea, that is more than one input line, then you will need to modify the $textarea array in the admin_templateconfig.php to add your new variable.

Note that if you want to use URL links in a Template Settings variable, then that variable must be defined in the $textarea array

Changes to the admin_templateconfig.php file should preferable be made using the TNG Mod Manager.

Mobile Mode Display

TNG version: 10.0

In order to get the Mobile Mode Display, you need to add the same logic to your template created in TNG V9 that was added to the index.php and topmenu.php files in TNG V10.

For example, in the index.php file for Template 4 you can search for

        if($sitever != "mobile") {

and add similar if statements to you template 40.

Related Links

TNG version: 11.1.2
TNG version: 9.0

Creating a new Template - TNG V9

Understanding Template Settings - TNG V9

Multi-language Template Variables

TNG version: 12.0.0

Template Manager