Setting and Displaying Site Variables
Introduction
Variables are containers for information such as text, HTML
and MGI tags. Variables allow you to "hold" information
until you need to display it further down the page or on another
page of the site. The information in page
variables is available from the point at which they are set
until they are overwriiten or until the end of the page that
is currently processing, whichever occurs first. The information
in site variables is stored in a database and is available from
the point at which they are set until they are overwritten by
a new value or deleted.
More often than not, the value of a variable is embedded in
the parameter of another MGI tag. Read
more about embedding.
In this example, a site variable is used to display the latest
version of a software release throughout a web site. Once the
version is set in a site variable, it can be displayed on any
page of the site by using the mgiGet tag. The following example
includes the version update page and one news page that displays
the software version.
MGI Tags
Steps
- Create a version update form.
- Create a version update processing page and open it in a
text editor.
- Insert the mgiSet tag with a Site scope.
- Save the version update processing page.
- Create a software news page and open it in a text editor.
- Insert the mgiGet tag with a Site scope.
- Save the software news page.
- FTP the version update form, version update processing page
and software news page to a web server running MGI.
- View the version update form in a web broswer and submit
the new version number.
Step 1: Create a version update form.
- Create a version update page named "versionupdate.mgi"
with form elements. In this example, the version update form
consists of a label and text field. Name each form element uniquely.
Enclose all form elements with HTML <FORM> tags and post
the form to the version update processing page (versionprocess.mgi).
-
- This is an version update form.
<FORM action="versionprocess.mgi" method="post">
<H2><CENTER>Version Update</CENTER></H2>
<P><CENTER>New Version Number:
<INPUT NAME="version" TYPE="text" SIZE="10">
<INPUT TYPE="submit" VALUE="Update Version">
</CENTER>
</FORM>
Step 2: Create a version update processing page and open
it in a text editor.
- Create a page named "versionprocess.mgi" to save
the version update in the site variable database. Open the version
update processing page in a text editing program that allows
you to view and modify the HTML and code of the page.
Step 3: Insert the mgiSet tag with a Site scope.
- Insert the beginning mgiSet tag, name parameter, scope parameter,
and ending mgiSet tag. In the name parameter, enter the name
of the site variable "Version". In the scope parameter,
enter "Site". In the body of the mgiSet tags, dynamically
enter the new version number from the version update form using
an mgiPostArgument tag.
-
- This is an example version update processing page.
<H2><CENTER>Version Process</CENTER></H2>
<P>The version has been updated to
<mgiPostArgument name="version">.</P>
<mgiSet name="Version" scope="Site">
<mgiPostArgument name="version">
</mgiSet>
Step 4: Save the version update processing page.
- Save the changes you have made to the version update processing
page.
Step 5: Create a software news page and open it in a text
editor.
- Create a page named "news.mgi" to display software
new. Open the software news page in a text editing program that
allows you to view and modify the HTML and code of the page.
Step 6: Insert the mgiGet tag with a Site scope.
- Insert your cursor in the HTML where you want the version
to appear and enter the mgiGet tag, name parameter and scope
parameter. In the name parameter, enter the name of the site
variable to display ("Version"). In the scope parameter,
enter "Site".
-
- This is an example software news page.
<H2><CENTER>Software News</CENTER></H2>
<CENTER>
<P><TABLE WIDTH="400" BORDER="0"
CELLSPACING="0" CELLPADDING="3">
<TR>
<TD><B>Latest Version</B>: Our software is constantly
updated to add new features and improve existing features.
Make sure you are up-to-date, download version
<mgiGet name="Version" scope="Site"> today!</TD>
</TR>
</TABLE></P>
</CENTER>
Step 7: Save the software news page.
- Save the changes you have made to the software news page.
Step 5: FTP the version update form, version update processing
page and software news page to a web server running MGI.
- Upload the version update form, version update processing
page and software news page from your local computer to the web
server using an FTP program.
Step 9: View the version update form in a web broswer and
submit the new version number.
- View the version update form (versionupdate.mgi) in a web
browser. Enter a new version number (e.g., "2.0") and
click the "Update Version" button. The new version
number is then set in the page variable named "Version".
View the software news page (news.mgi) in a web browser and the
version you set appears in the paragraph. For example, if you
updated the version to 2.0, the paragraph would read:
Latest Version: Our software is constantly
updated to add new features and improve existing features. Make
sure you are up-to-date, download version 2.0 today! |
- The version will display until the version update form is
submitted and the "Version" site variable is overwritten
with a new version number.
|