Embedding Multiple Tags in One 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 subject of a referral email is constructed from the visitor's name and message.

MGI Tags

  • Any MGI tag may be combined in variables and embedded in the parameter value of another MGI or HTML tag using the mgiGet tag.

Steps

  1. Create a referral form.
  2. Create a referral processing page and open it in a text editor.
  3. Construct the subject in a variable and embed the variable in the mgiSendMail tag.
  4. Save the referral processing page.
  5. FTP the referral form and referral processing page to a web server running MGI.
  6. View the referral form in a web browser and submit the referral.


Step 1: Create a referral form.

Create a referral page named "referral.mgi" with form elements. In this example, the referral form consists of form fields for your name, your email, subject, message, recipient name, and recipient email. Name each form element uniquely. Enclose all form elements with HTML <FORM> tags and post the form to the referral processing page (referralprocess.mgi).
 
This is an example referral form.
<FORM action="referralprocess.mgi" method="post">

<H2><CENTER>Refer Our Site</CENTER></H2>

<P><CENTER>Refer our site to a friend. 
Complete the form below and click 
&quot;Send Now&quot;.</CENTER></P>

<P><CENTER>
<TABLE BORDER="0" CELLSPACING="3" CELLPADDING="0">
  <TR>
    <TD ALIGN="RIGHT">Your Name:</TD>
    <TD>&nbsp;
<INPUT NAME="SenderName" TYPE="text" SIZE="30"></TD>
  </TR>
  <TR>
    <TD ALIGN="RIGHT">Your Email:</TD>
    <TD>&nbsp;
<INPUT NAME="SenderEmail" TYPE="text" SIZE="30"></TD>
  </TR>
  <TR>
    <TD ALIGN="RIGHT">Friend's Name:</TD>
    <TD>&nbsp;
<INPUT NAME="RecipientName" TYPE="text" SIZE="30"></TD>
  </TR>
  <TR>
    <TD ALIGN="RIGHT">Friend's Email:</TD>
    <TD>&nbsp;
<INPUT NAME="RecipientEmail" TYPE="text" SIZE="30"></TD>
  </TR>
  <TR>
    <TD ALIGN="RIGHT">Subject:</TD>
    <TD>&nbsp;
<INPUT NAME="Subject" TYPE="text" SIZE="30"></TD>
  </TR>
  <TR>
    <TD ALIGN="RIGHT">Message:</TD>
    <TD>&nbsp;
<TEXTAREA NAME="Message" ROWS="7" COLS="27">
</TEXTAREA></TD>
  </TR>
  <TR>
    <TD>&nbsp;</TD>
    <TD><P><CENTER>
<INPUT TYPE="submit" VALUE="Send Now"></CENTER></TD>
  </TR>
</TABLE></CENTER>

</FORM>

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

Create a page named "referralprocess.mgi" to send the referral email to the recipient. Open the referral processing page in a text editing program that allows you to view and modify the HTML and code of the page.

Step 3: Construct the subject in a variable and embed the variable in the mgiSendMail tag.

First, construct the subject of the email within the body of a page variable. Insert the beginning mgiSet tag, name parameter, and ending mgiSet tag. In the name parameter, enter "FullSubject". In the body of the mgiSet tags, enter mgiPostArgument tags for the sender's name and subject.
 
Second, enter the mgiSendMail tag, to parameter, from parameter, replyTo parameter, mailserver parameter, and subject parameter. Embed the recipient's email address in the "to" parameter. Enter the general info email address in the "from" parameter. Embed the sender's email address in the "replyTo" parameter. Enter the outgoing SMTP mailserver in the "mailServer" parameter. Embed the "FullSubject" page variable in the "subject:" parameter. In the body of the mgiSendMail tags, enter mgiPostArgument tags for the recipient's name, sender's name and sender's message.
 
This is an example referral processing page.
<H2><CENTER>Referral Submission</CENTER></H2>

<P><CENTER>Your referral has been sent to 
<mgiPostArgument name="RecipientName">
</CENTER></P>

<mgiSet name="FullSubject">
<mgiPostArgument name="SenderName"> says 
<mgiPostArgument name="Subject">
</mgiSet>

<mgiSendMail to={mgiPostArgument name="RecipientEmail"}
from="info@domain.com" 
replyTo={mgiPostArgument name="RecipientEmail"}
mailServer="mail.domain.com" 
subject={mgiGet name="FullSubject"}>
Dear <mgiPostArgument name="RecipientName">,
<mgiPostArgument name="SenderName"> thought you might 
be interested in our web site.  
<mgiPostArgument name="Message">
</mgiSendMail>

Step 4: Save the referral processing page.

Save the changes you have made to the referral processing page.

Step 5: FTP the referral form and referral processing page to a web server running MGI.

Upload the referral form and referral processing page from your local computer to the web server using an FTP program.

Step 6: View the referral form in a web browser and submit the referral.

View the referral form in a web browser. Complete and submit the form. The recipient is sent an email that appears with the following format. The subject of the email in this example is "Mark Willis says What Prices!".
Dear Andrea Shuster,

Mark Willis thought you might be interested 
in our web site. 
 
Hey Andrea, check out this site.  They have 
some great holiday deals.  Buy me something 
nice :)


[Return to the Embedding Menu]


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


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