Proudly hosted with Dreamhost

Save $20 when signing up for Dreamhost by using the promo code amnuts20
If you find these scripts useful to you, appreciate the free support, or are just an all round nice person, then why not donate a little dosh to encourage me to continue? Every little helps!
|
CafePress Box
This class will display a random product from your CafePress store. You can supply a simple template to control style, and have the output link directly to the shown product or simply to your main account. You can cache the results so you don't have to connect to the CafePress website all the time. Images can also be cached locally, and can be resized before caching.
class.cafepressbox.php
The main class file. Please view the comments for any instructions on how to call the functions.
14.41kb in size last modified Mar 20, 2007 at 9:52am 7908 views, 8137 downloads
test.cafepressbox.php
A test script so you can see how easy it is to use.
<?php
/** * $Id: test.cafepressbox.php 30 2006-03-24 20:15:56Z Andrew $ */
require('class.cafepressbox.php'); $cp =& new cafePressBox; $cp->setCacheDir('./cache'); $cp->setCacheTime(86400);
?> <html>
<body>
<table border="0" width="100%" cellpadding="10"> <tr> <td align="center">amnuts: link on, different template, cached, resized</td> <td align="center">amnuts: link off, standard template, no cache</td> </tr> <tr> <td align="center"> <?php
$cp->setStore('amnuts'); $cp->setResizeCachedImages(100); $cp->setCacheImages(true); $cp->setTemplate('<table border="0" cellpadding="5" cellspacing="0" width="150" style="border:3px solid #99CCFF;"><tr><td align="center">[IMG]</td></tr><tr><td align="center" style="background-color: #99CCFF; color: black; font-family : Verdana, Arial, sans-serif; font-size : 11px; text-decoration : none;">[TXT]</td></tr></table>'); $cp->displayItem(true);
?> </td> <td align="center"> <?php
$cp->setTemplate(); $cp->setCacheImages(false); $cp->displayItem(false);
?> </td> </tr> <tr> <td align="center">collingtons: link on, different template, cached, resized</td> <td align="center">collingtons: link off, different template, no cache</td> </tr> <tr> <td align="center"> <?php
$cp->setStore('collingtons'); $cp->setResizeCachedImages(80); $cp->setCacheImages(true); $cp->setTemplate('<table width="300" cellpadding="10" style="border:1px solid silver;"><tr><td>[IMG]</td><td valign="middle">[TXT]</td></tr></table>'); $cp->displayItem(true);
?> </td> <td align="center"> <?php $cp->setCacheImages(false); $cp->setTemplate('<div style="width:250px;">[TXT]</div><br>[IMG]'); $cp->displayItem(false);
?> </td> </tr> </table>
</body>
</html>
1.79kb in size last modified May 6, 2006 at 1:54pm 6034 views, 6215 downloads
|