Embedding One MGI Tag in a Parameter

Introduction

MGI supports embedded tags. That is, you can use one MGI tag within the parameter value of another MGI tag or within the parameter value of an HTML tag. The embedded MGI tag replaces the entire value of the MGI or HTML parameter including the quotation marks. Embedding allows you to create "dynamic" functions that change depending on the information entered or calculated.

Only one MGI tag can be embedded within the parameter of another MGI tag unless you use variables for an extended embedded function.

In this example, the color from a path argument is embedded in the background color of a page and in the comparison value of a conditional statement to determine the text that displays.

MGI Tags

  • Any MGI tag without a body can be embedded within the parameter value of another MGI or HTML tag.

Steps

  1. Create a link page with path arguments.
  2. Create a display page and open it in a text editor.
  3. Embed the mgiPathArgument tag in the HTML Body tag and the mgiConditional tags.
  4. Save the display page.
  5. FTP the link page and display page to a web server running MGI.
  6. View the link page in a browser and click a link.


Step 1: Create a link page with path arguments.

Create a page named "link.mgi" that contains text links to the display page (display.mgi). For each link, add a path argument with a background color. Name the path arguments"color".
 
This is an example link page.
<H2><CENTER>Backgrounds and Text</CENTER></H2>

<P>Choose a background color to test. The appropriate 
text color will be shown.</P>

<OL>
  <LI><a href="display.mgi?color=white">
View a white background.</a>
  <LI><a href="display.mgi?color=black">
View a black background.</a>
  <LI><a href="display.mgi?color=red">
View a red background.</a>
  <LI><a href="display.mgi?color=green">
View a green background.</a>
  <LI><a href="display.mgi?color=orange">
View an orange background.</a>
</OL>

Step 2: Create a display page and open it in a text editor.

Create a page named "display.mgi" to display the chosen color and the text that is most appropriate for that color background. Open the display page in a text editing program that allows you to view and modify the HTML and code of the page.

Step 3: Embed the mgiPathArgument tag in the HTML Body tag and the mgiConditional tags.

MGI tags are embedded the same in HTML and in the parameter of other MGI tags. To embed a tag, replace the quotation marks and value of the parameter with braces, the tag name and the tag's parameters. In this example, replace the quotation marks and value of the bgcolor parameter (in the body tag) with braces, the mgiPathArgument tag and the name parameter. Also replace the quotation marks and value of the lhs parameter (in the mgiConditional tag) with braces, the mgiPathArgument tag and the name parameter.
 
This is an example display page.
<HTML>  
<HEAD>
  <TITLE>Display</TITLE>
</HEAD>
<BODY BGCOLOR={mgiPathArgument name="color"}>

<CENTER>
<P>

<mgiIf lhs={mgiPathArgument name="color"} 
relationship="equals" rhs="white">
The best text color for a white background is black.
</mgiIf>

<mgiIf lhs={mgiPathArgument name="color"} 
relationship="equals" rhs="black">
<font color="white">The best text color for a 
black background is white.</font>
</mgiIf>

<mgiIf lhs={mgiPathArgument name="color"} 
relationship="equals" rhs="red">
The best text color for a red background is black.
</mgiIf>

<mgiIf lhs={mgiPathArgument name="color"} 
relationship="equals" rhs="green">
<font color="white">The best text color for a 
reen background is white.</font>
</mgiIf>

<mgiIf lhs={mgiPathArgument name="color"} 
relationship="equals" rhs="orange">
The best text color for an orange background 
is black.
</mgiIf>

</P>
</CENTER>
</BODY>
</HTML>

Step 4: Save the display page.

Save the changes you have made to the display page.

Step 5: FTP the link page and display page to a web server running MGI.

Upload the link page and display page from your local computer to the web server using an FTP program.

Step 6: View the link page in a browser and click a link.

View the link page in a web browser and click a link. The background color and text comment on the display page change according to the color path argument coded in the link you have chosen.


[Return to the Embedding Menu]


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


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