HomePHP Page 5 - Building A Quick-And-Dirty Guestbook With patGuestbook (part 2)
A Well-Formed Plan - PHP
In this concluding article of our two-part series on rapid guestbook implementation with patGuestbook, find out how to tweak patGuestbook a litle more by controlling the viewable entries, customizing the user interface, and protecting access to the administration module.
2. The template that displays a message to the user when moderation follows the
header.
<!-- message for moderated guestbook -->
<pattemplate:tmpl name="moderated"
visibility="hidden">
Note that this guestbook is moderated, and your entry will
only appear in
the list of entries once it has been approved by a moderator.<br><br>
</pattemplate:tmpl>
3. This is followed by a list of error messages, which are displayed when required
fields are left empty.
<!-- errors -->
<pattemplate:tmpl name="errors" visibility="hidden">
<table
width="400" cellpadding="0" cellspacing="0" border="0">
<tr>
<td class="text">
Ooops,
I've found some errors in your entries... please check them
again:<br> <img
src="skins/melonfire/img/px.gif" width="1" height="5" alt=""
border="0"><br>
<table width="100%" cellpadding="0" cellspacing="0"
border="0">
<pattemplate:tmpl
name="errorEntry" type="condition"
conditionvar="err_code"> <pattemplate:sub
condition="invalid_email"> <tr
valign="top"> <td class="text">• </td>
<td
class="text">{ERR_FIELD}: The email you entered is of a type unknown to
the
net as it exists today. Please enter something a little more
comprehensible.</td>
</tr> </pattemplate:sub> <pattemplate:sub
condition="invalid_url">
<tr
valign="top">
<td class="text">• </td>
<td class="text">{ERR_FIELD}:
The url you entered is of a type unknown to
the net as it exists today. Please
enter something a little more
comprehensible.</td> </tr> </pattemplate:sub>
<pattemplate:sub
condition="field_required">
<tr valign="top">
<td class="text">•
</td>
<td class="text">{ERR_FIELD}: This field is required, but you left
it
utterly empty. Please feed it something to make it happy :)</td> </tr>
</pattemplate:sub>
<pattemplate:sub
condition="rating_required">
<tr valign="top">
<td class="text">• </td>
<td
class="text">{ERR_FIELD}: You've forgotten to give a rating for this
item...</td>
</tr> </pattemplate:sub> </pattemplate:tmpl>
</table>
</td>
</tr>
</table>
<br>
</pattemplate:tmpl>
Feel free to edit the error messages above to reflect the personality and style
of your site.
4. Finally, the meat of the template - the form that is displayed to the user. As usual, there are pre-defined patGuestbook templates that I can work with for this section. Remember to be careful when tweaking these templates (unless, of course, you're comfortable with patTemplate, in which case, tweak away!).
For each field in the guestbook, I have two tags - one displaying the label and
the other displaying the form field to the user. For example, for the user's name, I've used the {LABEL_NAME} variable for the label and the {ENTRY_NAME} variable for the text box that is displayed to the user.