sendcard - the popular opensource PHP e-card script
 
 

 

 

 

 

Add a user-selectable stamp to your templates

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 a stamp. I added the following row somewhere in the table:

	<!-- Begin table row for setting the background image --> 
	<tr> 
	  <td width="140">Select a stamp:</td>
	  <td width="80%"> 
		<table width="275" border="0" cellspacing="3" cellpadding="0">
		  <tr align="center"> 
			<td><font size="-1">None</font></td>
			<td><img src="images/bg/santa.gif"></td>
			<td><img src="images/bg/tartan.jpg"></td>
			<td><img src="images/bg/snow.gif"></td>
		  </tr>
		  <tr align="center"> 
			<td> 
			  <input type="radio" name="user1" value="#FFFFFF" checked>
			</td>
			<td> 
			  <input type="radio" name="user1" value="santa.gif">
			</td>
			<td> 
			  <input type="radio" name="user1" value="tartan.jpg">
			</td>
			<td> 
			  <input type="radio" name="user1" value="snow.gif">
			</td>
		  </tr>
		</table>
	  </td>
	</tr>
	<!-- End table row for setting the background image --> 

Now open message.tpl and any other message templates you have created. Wherever you want the stamp to appear, add the code:
<img src="images/bg/{USER1}">
where the path to the image is the same one you used in the code in form.tpl

Stage 2: Test it

That's all the modifications made - now upload the files and send yourself a card to check it works.

Finale

This idea can be adapted to any other situations as required. Your imagination is your limit :-)
For another example, see this tutorial.