Creating a new Template - TNG V9

From TNG_Wiki
Jump to: navigation, search
Ambox notice.png The Creating a new Template - TNG V9 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.
TNG 10.0
TNG 9.0


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.

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 templateconfig.php yet.

Template folder with no templateconfig.php variables

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

Understanding Template Settings - TNG V9

Multi-language Template Variables