Creating a new Template - TNG V9
![]() |
The Creating a new Template - TNG V9 applies to TNG v9, 10, and 11 only, may not be not complete. For TNG v12 and later see Creating a new Template - TNG V12.
If you find errors or missing information in the instructions, please make the appropriate corrections and additions. |
|
The easiest way to create a new template in TNG V9 and above is to create a copy of an existing TNG template.
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
- create the variables for Template 40 in your templateconfig.php
- create the appropriate text variables for your new template variables
- 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.
Copy of Template Variables
In order to add the Template Settings capability for your new template, you must
- create a copy of the variables that are for the template you chose to copy
- paste them into a new file in Notepad++ for example
- rename the copied variables to the new template number you are creating
- for example if you copied template4 and created a template40, you would change the copied t4_... variables to t40_...
- copy the replaced variables from your new temporary file
- paste them in the templateconfig.php file in the appropriate collating sequence, for example t40_variables would be place just before the php ending ?>
- replace the template variables in the index.php and topmenu.php files for the template you copied, for example if you copied Template4 to Template40, you would replace all the t4_ variables with t40_ variables.
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 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 templates 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 t40_, of the 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
Creating a new Template - TNG V12