Mod Manager - Edit Parameters - prior to TNG 10.1
![]() |
The following information on Edit Parameters pertains to TNG V8 and V9.
|
|
Parameters
The TNG V8 and V9 Mod Manager supports creating Edit parameters that allow the user to tailor the TNG mod for their own installation, without having to edit the config file.
The following parameters can be used to create Edit parameters:
- %fileoptional:% is used after a %target:filename% keyword to indicate that if the file does not exist, no error should be generated. This is useful when describing parameters in a file that will be created during the mod installation
- %parameter: % is used to provide the parameter that can be changed via the Edit function. See the cfg files for examples below. This keyword triggers the Mod Manager to present the option to EDIT parameters after a mod has been installed. The Edit screen will use the %desc keyword to provide a label describing a parameter edit field. Once entered, the parameter value will be stored in the targeted file and will also be updated in the config file.
- %desc: % is used to provide a description of the editable parameter and the default value for the parameter which should be included within parentheses. See the cfg file examples below
Restrictions
TNG version: | ≥ 8.0 |
The following information on Edit Parameters pertains to TNG V8 and above:
- In order for the Mod Manager Edit function to work correctly, you must also specify a location to be verified and replaced.
- You cannot specify a target file that is to be changed before the Edit parameters for a newfile, otherwise the Edit button is not displayed and the new files do not get created.
- Parameters can only be edited in a single target specified within the mod config file.
- There must be a space before the equal sign (=) in the script variable, or the Mod Manager editor will not change its value.
- $variable = "tenspeed" works correctly
- $variable="tenspeed" will not be replaced by user value
- clearing a numeric value to nulls will result in a syntax error
- default values for the variable need to be specified within the %desc: keyword, so parentheses cannot be used as part of other text description within that section
- Parentheses should only be used to specify the default value within the %desc: section. In other words, you cannot use parentheses within the %desc: keyword without unpredictable results
TNG V8 and below
The following information on Edit Parameters pertains to TNG V8.
TNG version: | ≤ 8.1.2 |
* There is currently a problem where Edit adds extraneous backslashes as an escape character if Magic Quotes is enabled when the variable is specified as a single-quoted value such as in the County Outlines Mod. A fix is available for this problem.
- Quoted string parameters can only be edited if they are specified:
- within double-quotes where the quotes are not part of the default string value
- within single-quotes and the single-quotes should be specified as part of the default string value
The %parameter:% default value should not contain surrounding quotes; otherwise they will become part of the variable value. For example, if you want to change $variable = "tenspeed", and the default value or the value you enter via the Mod Manager editor is 'twelvespeed', the result will be $variable = "'twelvespeed'". Even if it does not kick up a server error, it probably won't work as desired.
Alternatively, if you use single-quoted variables, you will need to specify the single-quotes as part of the default value. For example in the County Boundary Mod example, the background and outline color variables are specified within single quotes.
TNG V9 and above
TNG version: | 9.0
and above |
The following information on Edit Parameters pertains to TNG V9 and above.
- single-quotes should not be used as the initial and default string values
The %parameter:% default value for string variables should NOT be specified within single quotes to avoid syntax errors. For example, if you want to change $variable = 'tenspeed' or $variable = "tenspeed" to nulls, you can now clear the entry. The default value should be specified as {tenspeed} since the Mod Manager uses the value within parentheseis for the restore. The default value should be specified within the %desc: % section.
Examples
Adjust Map Height Example
The following is an example of the editable parameter as coded in the Adjust Map Height Mod that allows changing the default value of 48 for the height of a map event entry, which is then used to calculate the height of the map based on how many events are being displayed.
1%target:extensions/adjustmapheight.php%
2
3Add edit capability to getperson.php for map event entry height
4%fileoptional:%
5%parameter:$entryheight:48%
6%desc:
7<div align="left" style="padding:10px">
8<fieldset style="padding:10px">
9<legend>Adjust Map Height Mod</legend>
10Here you can change the height of the average event.
11The mod uses this height to calculate the new height of the Google Map.<br />
12Calculate the height of the map on: Default is (48)
13<br /><br />
14You can find more information about this mod and calculates the height of what you should think
15about whether you think the map is too small at
16<a href="http://tng.lythgoes.net/wiki/index.php?title=Adjust_Map_Height_Mod">this Wiki page.</a>
17</fieldset>
18</div>
19%
20%location:%
21$entryheight =
22%end:%
23%trimreplace:%
24$entryheight =
25%end:%
Line 5 above shows the initial value assigned to the height Line 12 shows the default value that will be used for a Restore purposes.
County Outines Example
The following is an example of the editable parameter as coded in the County Outlines Mod that allows changing the outline and background color and when to generate the boundary outline, for the county (2) or city (3)
1%target:extensions/mapoutlinelib.php%
2%fileoptional:%
3%parameter:$detail_level:3%
4%desc:Detail level for which you want counties to be automatically outlined. Defaults to (2)
5<br /><em>0=None;2=county;3=city;4=address;9=all</em>%
6%location:%
7$detail_level =
8%end:%
9%trimreplace:%
10$detail_level =
11%end:%
12
13
14%parameter:$stroke_color:'#FFFF00'%
15%desc:Outline Color to use. Defaults to ('#ee0000') = Red Color Outline; for example, you could
16change the color outline to '#FFFF00'.<br />You <strong>must</strong> enclose the color code in
17single quotes, e.g. '#FFFF00'%
18%location:%
19$stroke_color =
20%end:%
21%trimreplace:%
22$stroke_color =
23%end:%
24
25%parameter:$fill_color:'#FFFFCC'%
26%desc:Background Color to use. Defaults to ('#ee0000') = Red Color background; for example, you
27could change the background color to '#FFFFCC'.<br />You <strong>must</strong> enclose the color
28code in single quotes, e.g. '#FFFFCC'%
29%location:%
30$fill_color =
31%end:%
32%trimreplace:%
33$fill_color =
34%end:%
TNG version: | ≤ 8.1.3 |
Note that then initial values and default values assigned in the highlighted lines in the above example being specified within single-quotes applies to TNG V8.1.3 and below only
TNG version: | ≥ 9.0 |
In TNG V9, no single-quotes should be used for the initial nor the default values. The code has been fixed to allow clearing the value of string variables. Numeric variables cannot be cleared to nulls without causing a syntax error.
Add Placelevel Example
The following is an example of the editable parameter as coded in the Google Maps - More Place Levels Mod that allows changing the values used to update the placelevels in the database.
Add edit capability to update_ChangePlaceLevels.php
%target:update_ChangePlaceLevels.php%
%fileoptional:%
%parameter:$chg_level_from:6%
%desc:Change original Place Level from [default:(6)]%
%location:%
$chg_level_from =
%end:%
%trimreplace:%
$chg_level_from =
%end:%
%parameter:$chg_level_to:8%
%desc:Change original Place Level to [default:(9)]%
%location:%
$chg_level_to =
%end:%
%trimreplace:%
$chg_level_to =
%end:%
Living Color Mod Example
In this example, we add a variable to globallib.php and make its value editable in the Mod Manager.=
1%target:globallib.php%
2%parameter:$livingColor:#990000%
3%desc:Flagged Person Color <br />Do do not use quotes!<br />
4Defaults to (#990000)%
5
6%location:%
7session_register('assignedtree');
8%end:%
9%insert:after%
10$livingColor = "#990000";
11define('LIVING_COLOR', $livingColor);
12%end:%
There are a few things to notice here.
- Line 2: the initial parameter value (#990000) is not enclosed in quotes, even though it is a string.
- Line 4: the default value is placed in parens so that whenever you are in the Mod Manager editor and press Read Existing Values from TNG files button, this value will replace whatever currently applies (after you press Confirm Edit).
- Line 10: the variable that is being placed in the target file must have a space between the variable name and the equal sign (=) that follows it. See the Restrictions above for a more detailed explanation.
- Line 11: by design, the variable '$livingColor', must be accessible inside a function in globallib.php. Since the scope of a defined constant (LIVING_COLOR) is global, we do not need to redeclare the variable inside the function, just use the constant.
Variable
The variable that can be edited in the extensions/adjustmapheight.php file is shown below:
$entryheight = 65; // add variable that can be edited by Mod Manager
Default
The default value for the parameter should be coded within parentheses in the %desc: section since the Mod Manager supports restoring the value. |
Restore
TNG version: | ≤ 8.1.3 |
TNG version: | ≥ 7.1 |
The Mod Manager will restore the default value in a mod config file when you click the Read Existing Values from the File button, as shown in the image above.
TNG version: | ≥ 9.0 |
In TNG V9, the button was changed to Restore default parameter values