|
Add user-selectable special effects to your templates
By silke
Preamble
Sendcard 3 offers two empty fields in the database designed for you to do this
kind of thing. The two fields in sendcard are called user1 and user2, and have
the respective template variables {USER1} and {USER2}. This tutorial will show
you how to use them to reach our aims.
Stage 1: Modify the templates
We need to add a field in form.tpl asking the user to pick an effect
to use. I added the following row somewhere in the table:
<!-- BEGIN effect_row -->
<tr>
<td width="140">Special Effect?</td>
<td width="80%">
<select name="user2">
<option value="" selected>None</option>
<option value="bubbles.js ">Bubbles</option>
<option value="bats.js">Bats</option>
<option value="leaves.js">Leaves</option>
</select>
</td>
</tr>
<!-- END effect_row -->
Check whether the AUTHOR SPECS at the top of form.tpl has the row
fieldsNotRequired['user2'] = true
in it. If it does not, the postcard sender will have to choose a special
effect otherwise the card will not be sent.
Now open message.tpl and any other message templates you have created.
Insert the following code into the body:
<script language="JavaScript" src="javascript/{USER2}"></script>
where the path to the javascript is the one where you have uploaded the
javascript files to, relative to sendcard.php. So, if sendcard.php is
at http://www.yoursite.com/sendcard/sendcard.php and the javascript files
are at http://www.yoursite.com/sendcard/javascript/ then the path used
above is correct. If however the javascript files were at http://www.yoursite.com/javascript/
then you'd change the above line to:
<script language="JavaScript" src="../javascript/{USER2}"></script>
Stage 2: Test it
That's all the modifications made - now upload the files and send yourself
a card to check it works.
You can find the javascript used here at Dynamic
Drive. When setting up the script, use the complete URL to your image
- for example http://www.yoursite.com/sendcard/javascript/bubbles.gif
|