The mgiCounter Tag

Tag Behavior

Use the mgiCounter tag to increment and display a text or graphic counter. Use the web-based administration interface to manage counters.


Tag Syntax

The mgiCounter tag has three modes. Each mode has different required and optional parameters. The modes of mgiCounter are:

  • process - Displays and/or increments a text or graphic counter.
  • admin - Creates a web-based interface to manage and reset counters
  • setValue - Sets a specified counter to a specified value.

Process Mode

The process mode of the mgiCounter tag has one required parameter and eleven optional parameters. The tag form is:

<mgiCounter name="Name" mode="process" type="Text/Graphic"
length="Whole Number" display="Yes/No" increment="Yes/No" 
font="FontName" fontFolderLocation="Folder Path" 
ignoreClientIPAddress="Yes/No" odbcDatasource="Source Name" 
odbcUsername="Name" odbcPassword="Password">

Required Parameters:

  • name - The name is the unique name of the counter.

Optional Parameters:

  • mode - The mode is the function that the mgiCounter tag performs. In "process" mode, the mgiCounter tag displays and/or increments the counter value. "Process" is the default mode of the mgiCounter tag.
  • type - The type parameter determines the appearance of the counter. If the type parameter value is "Text", then the counter is displayed as regular HTML text characters. If the type parameter value is "Graphic", then the counter is displayed as gif images in a specified font. The default value is "Text". If the type is set to "Graphic", then either the "font" or "fontFolderLocation" parameter is required.
  • length - The minimum number of digits the counter should display. If the length parameter is not included, the default behavior of the mgiCounter tag is to display the total number of digits for the current counter value (e.g., a counter value of 204 requires the display of 3 characters).
  • display - The display parameter determines if the counter value displays or is hidden. If the display parameter value is "Yes", then the counter displays on the page. If the display parameter value is "No", then the counter value does not display on the page. The default value is "Yes".
  • increment - The increment parameter determines if the counter value increases when processed. If the increment parameter value is "Yes", then the counter value increases when processed. If the increment parameter value is "No", then the counter value does not increase when processed. The default value is "Yes".
  • font - The font is the full name of the graphic font included with the mgiCounter tag that displays the counter value. To use the font parameter, you must set the "type" parameter value to "Graphic". The default font is "Odometer". See the list below for additional font names and displays.
  • fontFolderLocation - The fontFolderLocation is the relative path to the folder containing the ten custom graphic counter images. Custom graphic counter images must be saved in gif format and named with the following syntax:
    • 0.gif
    • 1.gif
    • 2.gif
    • 3.gif
    • 4.gif
    • 5.gif
    • 6.gif
    • 7.gif
    • 8.gif
    • 9.gif
  • ignoreClientIPAddress - The ignoreClientIPAddress parameter determines if the counter increments for visitor IP numbers that match the previous visitor's IP number. If the ignoreClientIPAddress parameter value is "Yes", then the counter increments for any IP number even if it matches the previous visitor's IP number. If the ignoreClientIPAddress parameter value is "No", then the counter only increments if the IP number of the current visitor does not match the IP number of the previous visitor. The default value is "Yes". This parameter can be used to create more accurate counts.
  • odbcDatasource (NT only) - The odbcDatasource is the name of datasource on the server that provides access information for an external ODBC database. If the odbcDatasource parameter is included, counter information will be stored in the specified ODBC database rather than the internal MGI database. Inquire with the server administrator for additional information about the use of ODBC databases. If you include the odbcDatasource parameter, the odbcUsername and odbcPassword parameters are required.
  • odbcUsername (NT only) - The odbcUsername is the username required to access the ODBC datasource. The odbcUsername parameter is required if you include the odbcDatasource parameter.
  • odbcPassword (NT only) - The odbcPassword is the code required to access the ODBC datasource. The odbcPassword parameter is required if you include the odbcDatasource parameter.

Included Font Names and Displays:

Font Name Font Display
 Odometer

 DigitBlueGlow

 Greeny

 RedDigital

 SmallBlue

 SaintFrancis

Admin Mode

The admin mode of the mgiCounter tag has one required parameter and four optional parameters. The tag form is:

<mgiCounter mode="admin" displayLimit="Integer"
odbcDatasource="Source Name" odbcUsername="Name" 
odbcPassword="Password">

Required Parameters:

  • mode - The mode is the function that the mgiCounter tag performs. In "admin" mode, the mgiCounter tag creates a web-based interface that allows you to add new counters, set or reset counter values and delete counters.

Optional Parameters:

  • displayLimit - The displayLimit is the maximum number of counters displayed per screen in the administration interface. The default value is 10. The maximum value of the displayLimit parameter is 50.
  • odbcDatasource (NT only) - The odbcDatasource is the name of datasource on the server that provides access information for an external ODBC database. If the odbcDatasource parameter is included, counter information will be stored in the specified ODBC database rather than the internal MGI database. Inquire with the server administrator for additional information about the use of ODBC databases. If you include the odbcDatasource parameter, the odbcUsername and odbcPassword parameters are required.
  • odbcUsername (NT only) - The odbcUsername is the username required to access the ODBC datasource. The odbcUsername parameter is required if you include the odbcDatasource parameter.
  • odbcPassword (NT only) - The odbcPassword is the code required to access the ODBC datasource. The odbcPassword parameter is required if you include the odbcDatasource parameter.

SetValue Mode

The setValue mode of the mgiCounter tag has three required parameters and three optional parameters. The tag form is:

<mgiCounter mode="setValue" name="Name" 
value="Integer" odbcDatasource="Source Name" 
odbcUsername="Name" odbcPassword="Password">

Required Parameters:

  • mode - The mode is the function that the mgiCounter tag performs. In "setValue" mode, the mgiCounter sets a specified counter to a specified value.
  • name - The name is the unique name of the counter.
  • value - The new value of the counter.

Optional Parameters:

  • odbcDatasource (NT only) - The odbcDatasource is the name of datasource on the server that provides access information for an external ODBC database. If the odbcDatasource parameter is included, counter information will be stored in the specified ODBC database rather than the internal MGI database. Inquire with the server administrator for additional information about the use of ODBC databases. If you include the odbcDatasource parameter, the odbcUsername and odbcPassword parameters are required.
  • odbcUsername (NT only) - The odbcUsername is the username required to access the ODBC datasource. The odbcUsername parameter is required if you include the odbcDatasource parameter.
  • odbcPassword (NT only) - The odbcPassword is the code required to access the ODBC datasource. The odbcPassword parameter is required if you include the odbcDatasource parameter.


Example Usage and Output

Text Counters

<mgiCounter name="index" type="Text" length="4" 
increment="Yes" display="Yes">

In this example, the counter value will display as regular text with a padding of 4 characters and increment every time the page is accessed. If the previous value of the counter was 257, then the counter will display the following when the page is accessed by any web site visitor:

0258

Graphic Counters

<mgiCounter name="about" type="Graphic" increment="Yes"
display="Yes" font="SaintFrancis" ignoreClientIPAddress="No">

In this example, the counter value will display the "SaintFrancis" font and increment every time a unique IP number accesses the page. If the previous value of the counter was 300234, then the counter will display the following when the page is accessed by a different web site visitor:

Hidden Counters

<mgiCounter name="home" display="No">

In this example, the counter increments every time the page is accessed, but the counter is not displayed. Hidden counters may be used for general page hit statistics.

Counter Admin

<mgiCounter mode="admin" displayLimit="25">

When you access a page with the mgiCounter tag in admin mode, the counter database administration screen displays. To add a new counter, enter the counter name, new value (if greater than zero) and click the "Add" button (Note: a new counter will be created automatically if you access a page with an mgiCounter tag in process mode and the counter's name does not exist). To set the counter value, enter a counter value beside the counter name in the "New Value" column, then click the "Set" button. To reset the counter value to zero, click the counter's "Reset" button. To delete a counter, click the counter's "Delete" button.

Set Value

<mgiCounter mode="SetValue" name="service" value="0">

In this example, the "service" counter is reset to "0".


Suggested Usage

  • Page Hit Statistics
  • Serialization


[Understanding MGI Menu] [Using MGI Menu] [Referencing MGI Menu]


[MGI Guides Main Menu] [User Guide Main Menu]