Mod Guidelines - Prior to TNG 10.0.3
The following Mod Manager Guidelines should be followed by the Mod Developer when creating mods that will be posted for others to install:
- file name
- custom text
- style additions
- coding standard
- adding files
Mod manager directive keywords are in the format %keyword:value% where there is no white space between the percent sign keyword colon and value. Directives should also start in the first column.
Mod File Names
|TNG version:||≥ 9.0|
Starting with TNG V9 the file names use mod_name_v.x.y.z for the .cfg file names and %version: numbers to identify the minimum version of TNG that a mod can be installed on, where the first 3 positions identify and the 4th position identifies the mod revision number
- v is the TNG version
- x is the TNG release,
- y is the TNG release modification number, and
- z is the TNG mod number used when having to make changes to the mod starting with 0.
For example, the first version of the mod in TNG V9 is numbered and named as 184.108.40.206, the z value for the TNG Mod number is 0 so that the mod number matches the TNG V9.0.0 and the last .0 indicates the original release of the mod.
See the TNG V9 version number below for additional examples where the mod number might not change with a new TNG release.
Configuration files for related mods should also be named so they sort together, for example:
|Description||File Name||TNG Wiki Article|
|Living Flag Backup / Restore||living_flag_backup_v220.127.116.11.cfg||Backup / Restore Living Flag|
|Living Flag Display||living_flag_display_v18.104.22.168.cfg||Living Flag Mod|
If the mod was originally named differently then a wiki redirect should be created.
Related with Install Sequence
If an install sequence on related mods needs to be designated, it could be entered as media-2 through media-4 as shown as illustrated below.
|Description||File Name||TNG Wiki Article|
|Media 2 - Show Table||media-2_show_table_v22.214.171.124.cfg||ShowTable Mod|
|Media 3 - Body Text for Translation||media-3_body_text_V126.96.36.199.cfg||Body Text for Translation|
|Media 4 - Tooltip||media-4_tooltip_v188.8.131.52.cfg||Tooltip Mod|
|Media 5 - Image Map Message||media-5_image_map_msg_v184.108.40.206.cfg||Image Map Message Mod|
Note that TNG Wiki article redirects can also be created as was done for the above media mods.
Subfolder for additional files
If a mod contains more than one file that needs to be copied from the mods folder during the install, it is recommended that a subfolder with the same name as used on the .cfg file or that can be easily related to the mod but excluding the version number should be used to contain the files that are copied so they will group together in the mods folder. So for example
would be related to the gmaps_add_4_placelevels_v220.127.116.11.cfg mod. Not using the version number in the sub-folder name will make it easier to keep the mod updated and prevent cluttering with folders all similarly named when only 1 is needed. However, if your mod provides a lot of copied files that change with different versions of the mod, then you should use a version number in the subfolder, like censusplus_v10001
The %name:Mod Name parameter used for the TNG mod config file should be the same name as used for the TNG Wiki article on the mod. It should also be closely related to the mod file name to avoid confusion when referring to a mod in the TNG Forum when the user requests help. Note that no whitespace should exist between the colon and the Mod Name.
%version:Vv.x.y.z% should be used for new config files to identify that the mod applies to TNG Vv where v is the TNG version, x is the TNG release, and y is the TNG release modification number. The z is the TNG mod revision number. For the first version of the mod in TNG V9, numbered and named as Mod_V18.104.22.168, the z value for the TNG Mod number is 0 so that the mod number matches the TNG V9.0.0 and the last .0 indicates the original release of the mod. Note that no whitespace should exist between the colon and the version number.
|TNG||Mod Version||Mod File name||z value||Meaning of the TNG Mod number|
|9.0.0||%version: V22.214.171.124%||filename_v126.96.36.199.cfg||0||first mod for a new TNG version|
|9.0.0||%version: V188.8.131.52%||filename_v184.108.40.206.cfg||1||fixed a bug in the Mod|
|9.0.0||%version: V220.127.116.11%||filename_v18.104.22.168.cfg||2||fixed another bug in the Mod|
|9.0.1||%version: V22.214.171.124%||filename_v126.96.36.199.cfg||2||no change required to the mod for new TNG release|
|9.0.2||%version: V188.8.131.52%||filename_v184.108.40.206.cfg||3||mod needed a change|
|9.0.2||%version: V220.127.116.11%||filename_v18.104.22.168.cfg||4||added new feature to mod|
|9.0.3||%version: V22.214.171.124%||filename_v126.96.36.199.cfg||4||no change required|
|9.1.0||%version: V188.8.131.52%||filename_v184.108.40.206.cfg||4||no change required|
|9.1.1||%version: V220.127.116.11%||filename_v18.104.22.168.cfg||5||change required for new TNG release|
Note that the first three values identify the minimum TNG version.release.mod on which the TNG mod can be installed. For example 9.1.0 indicates that TNG v9.1.0 is the minimum version this mod will install on. If the mod installs as is on the next major version of TNG it is not necessary to create a new version of the mod, so v22.214.171.124 could also apply to TNG v10
Note that if you include %newfile you should also update the version numbers in those new files being added to match the mod %version number.
The %Description:statement should be kept as brief as possible. However, it should provide information on the TNG modules being modified, who the mod developer is, and a link to the TNG Wiki article pertaining to the mod. Optionally, some mods might require other installation actions. Note that no whitespace should exist between the colon and the Mod Name.
The mod developer should be identified in the description.
TNG Wiki Article Link
A link to the TNG Wiki article, which uses the same value as specified in the %name: parameter for the mod should be included in the description using the target="_blank" as part of the URL so that article will open in a different window. This makes it easier for the TNG Users to check whether a new version of the mod exists.
If there are actions that must be taken either before or after installation of the mod, only a brief description of the required actions should be included in the mod description. Detailed steps for these actions should be documented in the TNG Wiki article, such as shown in After Installation Actions for the [[Template Settings - Multi-language Mod]] rather than creating readme files for the mod.
Both English folders
If your mod provides custom text, you must provide the $text variables for both
You should use both English and English-UTF8 when constructing a .cfg file since you don't know whether a mod user will be installing your mod on a system running as ISO-8859-1 (English) or UTF-8 (English-UTF8).
Note that users should not delete the languages/English folder on their site, since the Admin Help files are also contained in the English folder only and mods that provide custom text entries will require this folder.
If you support additional languages, TNG v10 now provides the equivalent of the Custom Text Mod that allows display of new text variables in English until you have can create the appropriate translations.
It is recommended that your text variable definitions be preceded by a comment line stating your Mod name and version. Likewise, add a comment line to end your list of variables. See example below.
To avoid conflicts with the Custom Text Files Mod is it recommended that text variables be inserted before the end of cust_text.php as shown in the code fragment below, where your code will replace lines 15-18 and 26-29.
%target:languages/English/cust_text.php% %location:% ?> %end:% %insert:before% // (Mod name), (mod version) $text['something'] = "these words"; $text['something more'] = "etc."; // End of (Mod name) %end:% %target:languages/English-UTF8/cust_text.php% %location:% ?> %end:% %insert:before% // (Mod name), (mod version) $text['something'] = "these words"; $text['something more'] = "etc."; // End of (Mod name) %end:%
Containing other languages
Mods containing other language custom text should include the %fileoptional:% parameter so that the installation will be bypassed if the user deleted the language folder.
Note that %newfile, %copyfile, or %copyfile2 cannot follow the %fileoptional section so these parameters should follow the English cust_text.php sections or use the %target:files% directive added in TNG V10.0.3
Containing Foreign Accents
If you create custom text that includes foreign accented characters, you should use the HTML special character so that the change can be installed in both the French and French-UTF8 cust_text.php for example and display correctly whether you are using ISO-8859-1 or UTF-8 for your TNG charset.
The issue is that if you create the mod as ANSI encoded, the accented characters will be mangled when installing on a UTF-8 TNG site and vice versa if you encode the mod as UTF-8 without BOM it will get mangled on an ISO-8859-1 TNG site. Using the HTML special characters avoids the mangling if an ANSI encoded file is installed on a UTF-8 environment.
The alternative is creating both an ANSI and UTF-8 file, which is probably a valid alternative for installing cust_text.php changes for your own site languages that you are not publishing.
Starting with TNG 8.1.0, since
- TNG supports selecting the template to be used on the site from the Admin >> Setup >> Template Settings
- each template has its own mytngstyle.css override
- there is not an independent style sheet override capability,
mods that contain style changes or additions can provide the change in one of two ways:
- target the change not only for the default css/mytngstyle.css but also for each templates/templateN/css/mytngstyle.css where N is the template number
- target the change to the TNG genstyle.css since you don't know what template the mod installer will be using.
If you want to keep your style additions or changes to the documented override mytngstyle.css, you should use as target
- templates/template1/css/mytngstyle.css for all TNG distributed templates from 1 through 14
Mods created for your own site that are not published for others to use only need to target the template you are using.
The alternative to providing style changes is to target the genstyle.css for them, but if you do be aware that your mod will be impacted with every TNG upgrade since genstyle.css is one of the files that is always changed.
If your mod targets genlib.php or getperson.php, then it may make sense to target your style change against genstyle.css, since both of those modules are normally replaced with each upgrade.
Coding to Standards
The following was extracted from the User2 list, requesting that mods be coded to XHTML coding standards.
Could I make a plea through the lists to persuade mod contributors to make sure that the config files they are offering are of a proper coding standard. I realise that it can be difficult in your own site to understand the vagaries of and differences between the languages of html and php.
The syntax of mod manager adds a third layer to this array. However, the basic structure of TNG8 is set at xhtml1.0 transitional and I believe that if a mod is offered to the end user population, the resulting code should conform to that standard. There is an excellent resume of the syntactic rules for xhtml in the TNG wiki which covers the majority of the requirements: XHTML_Validation_-_Transitional
It is quite possible that your browser will interpret what should be there if you don't conform to these requirements. However you should make sure that your config file is NOT carrying over such errors as:
- Paired tags not closed (eg: Every opening paragraph tag
be followed by a closing
- Self closing tags not closed (eg the image tag should be closed thus: <img ..... />
- Tags should be nest correctly (eg
<b><i> ... </i></b>is correct;
<b><i> ... </b></i> is not)
- Attribute values must be literals (eg use border="0"; not border=0)
- Image (and some other) tags require an alt attribute (even if it is declared empty ie alt="")
Perhaps the simplest way to check your coding is to submit a specimen page for validation after you have added it (your home page is the easiest choice) to the w3c validation service. You should aspire to a Green correct validation result:
I realise there are people who don't consider validation to be particularly important but essentially if you are going to use a language you should use it properly. For people who do, a poorly written mod is not worth the effort. Posted by Alan Craxford on the User2 List on 31 January 2011
There are two separate Mod Manager parameters that can be used to add new files in a TNG mod cfg file:
- %copyfile or $copyfile2
|TNG version:||≤ 10.0.2|
|TNG version:||≥ 7.1|
|TNG version:||≥ 10.0.3|
The %newfile parameter includes the new file source directly in the .cfg file. Note that there is a known side effect that installing or removing a file that contains a long %newfile takes longer to process.
There are two flavors of the %copyfile parameter.
%copyfile: copies the file to the TNG root directory: .
%copyfile2: copies the file to a specified location
When using the copy file capability, you should create a subdirectory in the mods directory to contain the files used as the source for the copyfile function for your TNG mod.
Note that %copyfile cannot copy the entire content of a folder, you need to specify %copyfile or %copyfile2 for each file within the folder.
It is recommended that you install new files or copied files to the Mod Manager extensions folder so that your code snippets are not intermixed with the TNG code. There are some cases though where your code might need to be in the TNG root folder in order to work correctly.
Also, currently you cannot rename the extension folder, since the folder name is hard-coded as the destination folder in the $newfile or %copyfile parameters. For example,
%copyfile2:rip_prevention/rip_warning.html:extensions/rip_warning.html% %copyfile2:rip_prevention/rip_ban.html:extensions/rip_ban.html% %copyfile2:rip_prevention/showaccess.php:extensions/showaccess.php% %copyfile2:rip_prevention/check_access.php:extensions/check_access.php%