The mgiSet Tag

Tag Behavior

Use the mgiSet tag to create a variable with a specific scope and value (see also mgiGet).Variables are containers for text, numbers, calculations, results, etc. that can be used after they are created (i.e., set) throughout a single page (page variables) or throughout an entire web site (site variables).


Tag Syntax

The mgiSet tag has a beginning tag with one required parameter and five optional parameters, a body, and an ending tag. The tag form is:

<mgiSet name="Name" scope="Page/Site" defaultValue="Value" 
odbcDatasource="Source Name" odbcUsername="Name" 
odbcPassword="Password">
Variable Value
</mgiSet>

Required Parameters:

  • name - The name is the name of the variable to create. Variable names must be unique within a scope.

Optional parameters:

  • scope - The scope is the type of variable to create. "Page" variables are are created at the location they are set on a page and are available to display until the end of the page. "Site" variables are created and stored in an internal MGI database and are available to display after they are set on any page in a web site. The default scope is "Page".
  • defaultValue - The defaultValue is the text that is set in the variable if the variable value is blank. If a default value is not specified, an empty string (blank) is set.
  • 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, site variable information will be retrieved from 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

<mgiSet name="CustomerSubject">
Welcome <mgiPostArgument name="FirstName"> 
<mgiPostArgument name="LastName">
</mgiSet>

<mgiSendMail to={mgiPostArgument name="Email"} 
from="registration@domain.com" 
subject={mgiGet name="CustomerSubject"} 
mailserver="mail.domain.com">
<mgiGet name="CustomerSubject">

You are now registered for our online service.
</mgiSendMail>

Variables are so versatile that you could use them in combination with almost any other MGI tag. In this example, a page variable is used to combine information from a form submission. The information is then used in the subject of an email that is sent to a customer.


Suggested Usage

  • Storage of Information
  • Combining Information from Multiple Sources (Post Arguments, Path Arguments, Variables, etc.)
  • Site-wide Includes


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


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