## ## Document History ## ## Created (peeje01) ## 27-Apr-1999 (peeje01) ## Change include file name from -h.html to _h.html ## 02-Apr-2004 (fanra01) ## Bug 112091 ## Editorial changes from griel02. ##
You should see the following macro command displayed:
<!-- #ICEAnd following that you should see the sample output:
| comporder | title | playwright | performed | acts | type |
|---|---|---|---|---|---|
| 1 | Two Gentlemen of Verona | Shakespeare | 1598 | 5 | comedy |
| 2 | Taming of The Shrew | Shakespeare | 5 | comedy | |
| 3 | Henry VI part 1 | Shakespeare | 1591 | 5 | history |
| 4 | Henry VI part 3 | Shakespeare | 1595 | 5 | history |
| 5 | Titus Andronicus | Shakespeare | 5 | tragedy |
ii_rowcount = 5
<html>
<head>
<title>Shakespeare's Plays</title>
</head>
<body>
<h1>Shakespeare's Plays</h1>
<!-- #ICE
DATABASE = `icetutor`
SQL=`select * from plays`
TRANSACTION=`Complete`
CURSOR=`Works`
ROWS=`5`
TYPE=`TABLE`
-->
</body>
</html>
If you have already registered the file you can now view it in the administration tool or by loging on to your site and specifying its URL.
Notice that the only way or retrieving the next set of rows is by reloading the page. (Press the Refresh button on your browser.)
<html>
<head>
<title>Shakespeare's Plays</title>
</head>
<body>
<h1>Shakespeare's Plays</h1>
<!-- #ICE
DATABASE = `icetutor`
SQL=`select * from plays`
TRANSACTION=`Complete`
CURSOR=`Works`
ROWS=`5`
TYPE=`TABLE`
-->
<p>
<FORM ACTION="/ice-bin/oiice.dll/playgroup/plays[play_all.html]"
METHOD="POST">
<INPUT TYPE="submit" NAME="More" VALUE="More" ALT="Show more plays">
</FORM>
</body>
</html>
<hr width="50%" >
<h2>Where would you like to go now:</h2>
<table border=0 cellspacing=3>
<tr>
<td>
<A HREF="/ice-bin/oiice.dll/plays[play_home.html]">Globe Home Page:</A>
<td>
<A HREF="/ice-bin/oiice.dll/plays[play_home.html]">
<img src="OldGlobe.gif" alt="Return to Globe Home Page"
</A>
<tr>
<td>
<p>
<A HREF="/ice-bin/oiice.dll/plays[play_login.html]?ii_action=disconnect">logout:<A>
<td>
<A HREF="/ice-bin/oiice.dll/plays[play_login.html]?ii_action=disconnect">
logout GIF
</A>
</table>
<hr>
Clearly we could insert this directly into our file. And then every other one that we create. And then re-visit every file whenever we wish to change something. You get the idea. It would be much easier to have one version of this in a seperate file and INCLUDE it as needed. To do this, save the code in the file play_SessionControl_h.html and add the include line to the file play_all.html.
Note: Any include files need to be registered with the ICE server.
<html>
<head>
<title>Shakespeare's Plays</title>
</head>
<body>
<h1>Shakespeare's Plays</h1>
<!-- #ICE
DATABASE = `icetutor`
SQL=`select * from plays`
TRANSACTION=`Complete`
CURSOR=`Works`
ROWS=`5`
TYPE=`TABLE`
-->
<p>
<FORM ACTION="/ice-bin/oiice.dll/playgroup/plays[play_all.html]"
METHOD="POST">
<INPUT TYPE="submit" NAME="More" VALUE="More" ALT="Show more plays">
</FORM>
<!-- #ICE REPEAT INCLUDE=`plays[play_SessionControl_h.html]` -->
</body>
</html>
<html>
<head>
<title>Shakespeare's Plays</title>
</head>
<body>
<h1>Shakespeare's Plays</h1>
<!-- #ICE
DATABASE = `icetutor`
SQL=`select * from plays`
TRANSACTION=`Complete`
CURSOR=`Works`
ROWS=`5`
TYPE=`TABLE`
-->
<!-- #ICE DECLARE=`session.e_playTxn=Complete` -->
<!-- #ICE DECLARE=`session.e_playTxnCommitted=FALSE` -->
<p>
<FORM ACTION="/ice-bin/oiice.dll/playgroup/plays[play_all.html]"
METHOD="POST">
<INPUT TYPE="submit" NAME="More" VALUE="More" ALT="Show more plays">
</FORM>
<!-- #ICE REPEAT INCLUDE=`plays[play_SessionControl_h.html]` -->
</body>
</html>
| Prefix | Scope Level |
| s | Server |
| e | sEssion |
| p | Page |
We now need some code to use these variables to commit the transaction at the appropriate time. The code that achieves this conditional transaction commital appears below:
<!-- #ICE REPEAT IF (DEFINED (e_playTxnCommitted)) THEN=`` ELSE=`<!-- #ICE DECLARE=``session.e_playTxnCommitted=TRUE`` -->` --> <!-- #ICE REPEAT IF (DEFINED(e_playTxn) AND (`:e_playTxnCommitted` != `TRUE`)) THEN=`<!-- #ICE COMMIT=``:e_playTxn`` --><!-- #ICE DECLARE=``session.e_playTxnCommitted=TRUE`` -->` -->
We add an ICE IF statement to our next document. Suffice it to say for now that the first part of this code tests if the variable e_playTxnCommitted exists; if it does not then it is created and set to the value TRUE. We need to do this because the first time we visit the home page, no variables will be set.
Then, if the variable e_playTxn exists and the transaction has not yet been committed, it is committed. We need to perform these checks because it is an error to commit a nonexistent transaction.
It only remains to include this file in our home page, play_home.html as follows:
<html>
<head>
<title>Shakespeare's Plays Home Page</title>
</head>
<body>
<center>
<h1>Shakespeare's Plays Home Page</h1>
</center>
This is the home page for Shakespeare's plays hosted on the server <b>globe</b>
<h2>
View Shakespeares Plays
</h2>
<!-- #ICE REPEAT INCLUDE=`plays[play_TxnCndCmt_h.html]` -->
<ol>
<li> <a href="/ice-bin/oiice.dll/playgroup/plays[play_all.html]">All</a>
</ol>
Please
<A HREF="/ice-bin/oiice.dll/plays[play_login.html]?ii_action=disconnect">logout</A>,
don't time out!
<!-- // #ICE REPEAT FUNCTION=`play_NewOrder.newOrder`
HTML=`<hr>test: next order number is :out_orderNumber<hr>`
-->
</body>
</html>
In this example we showed how to create a macro statement with the design tool. We embedded the macro into a simple Web Deployment Option document.
We took advantage of the cursor feature to add a More button to the document, enabling us to view the sequence of plays by subset.
Finally we arranged to commit the transaction upon returning to the home page. This code was placed in a seperate file and INCLUDEd into the home page and the play_all.html document. Communication of the transaction name was achieved with web Deployment Optionsession variables
The next page illustrates the use of the if keywords.