At this point, I have identified the layout for the pages, and also shown you the menu that will be displayed on each page. Now for the most important item - connecting all this up to the patGuestbook database.
Here's the code:
<table border="0" cellpadding="0" cellspacing="0">
<tr>
<td class="textinvert"
colspan="3">
Welcome to {GB_NAME}!<br><br>
</td>
</tr>
</table>
<pattemplate:tmpl
name="entry">
<pattemplate:tmpl name="displayName" visibility="hidden" varscope="entry"
type="simpleCondition"
requiredVars="ENTRY_NAME">
<table width="550" cellpadding="0" cellspacing="1"
border="0">
<tr>
<td>
<table width="100%" cellpadding="6" cellspacing="0"
border="0">
<tr>
<td
class="head" >By
<b>{ENTRY_NAME}</b> on {ENTRY_DATE}</td>
</tr>
</table>
</td>
</tr>
</pattemplate:tmpl>
<tr>
<td
class="text">
<table border="0" cellpadding="0" cellspacing="0"
width="100%">
<tr>
<td>
<br>
<table border="0" cellpadding="0"
cellspacing="2">
<pattemplate:tmpl
name="displayEmail"
visibility="hidden" varscope="entry" type="simpleCondition"
requiredVars="ENTRY_EMAIL">
<tr valign="top">
<td class="text"
nowrap><b>{LABEL_EMAIL}</b></td>
<td
class="text"> : </td>
<td class="text"><a
href="mailto:{ENTRY_EMAIL}">{ENTRY_EMAIL}</a></td>
</tr>
</pattemplate:tmpl>
<pattemplate:tmpl
name="displayHomepage"
visibility="hidden" varscope="entry" type="simpleCondition"
requiredVars="ENTRY_HOMEPAGE">
<tr valign="top">
<td class="text"
nowrap><b>{LABEL_HOMEPAGE}</b></td>
<td class="text"> : </td>
<td class="text"><a href="{ENTRY_HOMEPAGE}"
target="_blank">{ENTRY_HOMEPAGE}</a></td>
</tr>
</pattemplate:tmpl>
<pattemplate:tmpl
name="displayEntry"
visibility="hidden" varscope="entry" type="simpleCondition"
requiredVars="ENTRY_ENTRY">
<tr>
<td colspan="3"><img
src="skins/melonfire/img/px.gif"
width="1" height="5" alt=""
border="0"></td>
</tr>
<tr valign="top">
<td class="text"
nowrap><b>{LABEL_ENTRY}</b></td>
<td class="text"> : </td>
<td class="text">{ENTRY_ENTRY}</td>
</tr>
</pattemplate:tmpl>
<pattemplate:tmpl name="ratings"
visibility="hidden">
<tr>
<td colspan="3"><img
src="skins/melonfire/img/px.gif"
width="1" height="5" alt=""
border="0"></td>
</tr>
<tr valign="top">
<td class="text"
colspan="3"><b>Ratings</b></td>
</tr>
<pattemplate:tmpl
name="ratingEntry">
<tr valign="top">
<td class="text"
nowrap><b>
· {RATING_LABEL}</b></td>
<td
class="text"> : </td>
<td
class="text">{RATING_VALUE}</td>
</tr>
</pattemplate:tmpl>
</pattemplate:tmpl>
</table>
<img src="skins/melonfire/img/px.gif" width="1"
height="5"
alt="" border="0"><br>
</td>
</tr>
</table>
</td>
</tr>
</table>
<img src="skins/melonfire/img/px.gif"
width="1" height="20" alt=""
border="0"><br> </pattemplate:tmpl>
<table
width="550" cellpadding="1" cellspacing="0" border="0">
<tr>
<td>
<table
width="100%" cellpadding="3" cellspacing="0"
border="0">
<tr>
<pattemplate:tmpl
name="previouspage"
type="condition" conditionvar="URL_PREVIOUSPAGE">
<patTemplate:sub
condition="default">
<td
class="text" nowrap width="33%">
<a href="{URL_PREVIOUSPAGE}"
style="text-decoration:none"><<
previous page</a>
<br>
</td>
</patTemplate:sub>
<patTemplate:sub
condition="empty">
<td width="33%"><img
src="skins/melonfire/img/px.gif"
width="1" height="1" alt=""
border="0"></td>
</patTemplate:sub>
</pattemplate:tmpl>
<td align="center" class="text" width="33%"><a
href="{URL_ADDENTRY}"
style="text-decoration:none">add entry</a></td>
<pattemplate:tmpl
name="nextpage"
type="condition" conditionvar="URL_NEXTPAGE">
<patTemplate:sub
condition="default">
<td
class="text" align="right"
nowrap width="33%">
<a href="{URL_NEXTPAGE}"
style="text-decoration:none"
>next page >></a>
<br>
</td>
</patTemplate:sub>
<patTemplate:sub
condition="empty">
<td width="33%"><img
src="skins/melonfire/img/px.gif"
width="1" height="1" alt=""
border="0"></td>
</patTemplate:sub>
</pattemplate:tmpl>
</tr>
</table>
</td>
</tr>
</table>
Chaos, you're thinking...and rightly so. But let me help make some sense of it.
1. First, the page header, displaying the name of the guestbook.
<tr>
<td class="textinvert" colspan="3">
Welcome to {GB_NAME}!<br><br>
</td>
</tr>
{GB_NAME} is a special patGuestbook template variable that will be replaced by
the name of the guestbook specified at run time - in this example, "Voice of the People".
2. Next, I have to define the template used for display of each field in the guestbook. In this example, I would like to display the name of the user along with the time at which the entry was saved.
<pattemplate:tmpl name="displayName" visibility="hidden" varscope="entry"
type="simpleCondition"
requiredVars="ENTRY_NAME"> <table width="550"
cellpadding="0" cellspacing="1"
border="0">
<tr>
<td>
<table width="100%" cellpadding="6" cellspacing="0"
border="0">
<tr>
<td
class="head" >By
<b>{ENTRY_NAME}</b> on {ENTRY_DATE}</td>
</tr>
</table>
</td>
</tr>
</pattemplate:tmpl>
Once I am done with the user's name via the {ENTRY_NAME} and {ENTRY_DATE} variables,
I can proceed to the user's email address and URL.
<pattemplate:tmpl name="displayEmail" visibility="hidden" varscope="entry"
type="simpleCondition"
requiredVars="ENTRY_EMAIL">
<tr valign="top">
<td
class="text"
nowrap><b>{LABEL_EMAIL}</b></td>
<td
class="text">
: </td>
<td class="text"><a
href="mailto:{ENTRY_EMAIL}">{ENTRY_EMAIL}</a></td>
</tr>
</pattemplate:tmpl>
<pattemplate:tmpl
name="displayHomepage"
visibility="hidden" varscope="entry" type="simpleCondition"
requiredVars="ENTRY_HOMEPAGE">
<tr valign="top">
<td class="text"
nowrap><b>{LABEL_HOMEPAGE}</b></td>
<td class="text"> : </td>
<td class="text"><a href="{ENTRY_HOMEPAGE}"
target="_blank">{ENTRY_HOMEPAGE}</a></td>
</tr>
</pattemplate:tmpl>
Once again, two special patGuestbook variables -{ENTRY_EMAIL} and {ENTRY_HOMEPAGE}
- are used to retrieve the information entered by the user. I can also display the appropriate labels for each field via the {LABEL_EMAIL} and {LABEL_HOMEPAGE} variables.
How about displaying the heart of the guestbook - the user's comments?
<pattemplate:tmpl name="displayEntry" visibility="hidden" varscope="entry"
type="simpleCondition"
requiredVars="ENTRY_ENTRY"> <tr> <td colspan="3"><img
src="skins/melonfire/img/px.gif"
width="1" height="5" alt=""
border="0"></td> </tr> <tr valign="top">
<td class="text"
nowrap><b>{LABEL_ENTRY}</b></td>
<td
class="text"> : </td>
<td class="text">{ENTRY_ENTRY}</td>
</tr>
</pattemplate:tmpl>
Finally, the rating field, which is also fairly straightforward.
<pattemplate:tmpl name="ratings" visibility="hidden">
<tr>
<td colspan="3"><img
src="skins/melonfire/img/px.gif"
width="1" height="5" alt="" border="0"></td>
</tr>
<tr valign="top">
<td class="text"
colspan="3"><b>Ratings</b></td>
</tr>
<pattemplate:tmpl
name="ratingEntry">
<tr valign="top">
<td class="text"
nowrap><b>
· {RATING_LABEL}</b></td>
<td class="text"> : </td>
<td class="text">{RATING_VALUE}</td>
</tr>
</pattemplate:tmpl>
</pattemplate:tmpl>
One of the configuration variables in the guestbook is the number of entries
to be displayed on a single page. So, I also need to add paging logic, and a link to add new entries to the system.
<table width="550" cellpadding="1" cellspacing="0" border="0">
<tr>
<td>
<table
width="100%" cellpadding="3" cellspacing="0"
border="0">
<tr>
<pattemplate:tmpl
name="previouspage"
type="condition" conditionvar="URL_PREVIOUSPAGE">
<patTemplate:sub
condition="default">
<td
class="text" nowrap width="33%">
<a href="{URL_PREVIOUSPAGE}"
style="text-decoration:none"><<
previous page</a>
<br>
</td>
</patTemplate:sub>
<patTemplate:sub
condition="empty">
<td width="33%"><img
src="skins/melonfire/img/px.gif"
width="1" height="1" alt=""
border="0"></td>
</patTemplate:sub>
</pattemplate:tmpl>
<td align="center" class="text" width="33%"><a
href="{URL_ADDENTRY}"
style="text-decoration:none">add entry</a></td>
<pattemplate:tmpl
name="nextpage"
type="condition" conditionvar="URL_NEXTPAGE">
<patTemplate:sub
condition="default">
<td
class="text" align="right"
nowrap width="33%">
<a href="{URL_NEXTPAGE}"
style="text-decoration:none"
>next page >></a>
<br>
</td>
</patTemplate:sub>
<patTemplate:sub
condition="empty">
<td width="33%"><img
src="skins/melonfire/img/px.gif"
width="1" height="1" alt=""
border="0"></td>
</patTemplate:sub>
</pattemplate:tmpl>
</tr>
</table>
</td>
</tr>
</table>
The {URL_PREVIOUSPAGE} and {URL_NEXTPAGE} variables are used to display the links
to the previous and next page, if required. the {URL_ADDENTRY} variable contains the URL that allows users to add a new entry to the guestbook.
Please enable JavaScript to view the comments powered by Disqus. blog comments powered by