ExperShop DynHtml tutorial
Please email any bug reports, comments or suggestions to ExperLog's Online Support
DynHtml StatementsFor a complete DynHtml statements quick reference, Click Here.
TutorialDynHtml is the way for ExperShop to publish database content in HTML pages:
The main work for a shop administrator who wants to customize a shop is writing and maintaining DynHtml pages.
In the ExperSHOP
Lite sample shop, the DynHtml pages are in the
This tutorial details a DynHtml example, step by step.
Listing products by departmentThe DynHtml page detailed here displays the list of all products in a given shop department. The output looks like this:
Now, let's have a look at the DynHtml source code expanded by ExperSHOP to generate this output.
DynHtml sourceDynHtml is a blend of HTML and ExperSHOP statements, interpreted and expanded at run time.
Look at the source: you can find HTML tags, and statements like
allow to query the database, and include the query results in the generated
$DefineSql LISTPROD SELECT ProdId, Name, ProdImage,
How it worksLet's have a look, step by step, at the DynHtml code:
define an SQL query to list the products contained in a shop department;
$DefineSql LISTPROD SELECT ProdId, Name, ProdImage,Back to HTML now:
<HTML> <HEAD> <TITLE>List Products</TITLE> </HEAD> <BODY BGCOLOR=#ffffff> <CENTER>Now, let's execute the query we defined before:
$ExecSql LISTPRODIf there was no result (if there's no product in the department), display "No Product Available" in the customer's browser:
$IfNoResult LISTPROD <h2>No Product Available</h2>Else, display the product list; first, let's display a table header, that looks like this :
$Else <TABLE BORDER> <TR> <TD ALIGN="CENTER"> <B><FONT SIZE=-1>Product Name</FONT></B> </TD> <TD ALIGN="CENTER"> <B><FONT SIZE=-1>Price</FONT></B> </TD> <TD ALIGN="CENTER"> <B><FONT SIZE=-1>Add to cart</FONT></B> </TD> </TR>... then, a table line for each product in the department, that looks like this:
For that, we'll use ExperSHOP's
to loop on the tuples returned by the database query:
$LoopOnResults LISTPROD prod <TR>That statement means we loop on the LISTPROD query results using a variable named "prod" ("prod" is the name we assign to the data tuple).
link above: if the customer clicks it, the
<TD ALIGN=CENTER> <A HREF="com.expershop.lite.ExperSHOP?$COOKIE$&Page=Now, display the product's price:
<TD ALIGN="CENTER">$(.00)prod:Price$</TD>(.00) is a format directive, that tells the value should be displayed with 2 decimal digits, with default values of "0" (for instance, 20.123 will be displayed as 20.12, and 20.1 as 20.10).
the "Add to cart" link: if the customer clicks it, the
<TD ALIGN="CENTER"> <FONT SIZE="-1"> <A HREF="com.expershop.lite.ESCartServlet?$COOKIE$&Page=ESViewCart.tmpl
$EndLoopNow the loop on the products list is ended, let's end with the table:
</TABLE>The table we displayed looks like this:
$EndifNow, it's the end of the HTML page: