andy's php projects
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
Script and site usage:
All of the scripts on this site are provided free for non-commerical, personal or non-profit use. 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? If you wish to use any of these in a commercial system, please refer to the payment plan.


test.class works for 3 items not more, Why ?

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    php.amnuts.com Forum Index -> CafePress Box
View previous topic :: View next topic  
Author Message
adjamlotfi
Newbie


Joined: 23 Feb 2004
Posts: 8

PostPosted: Tue Feb 24, 2004 4:00 pm    Post subject: test.class works for 3 items not more, Why ? Reply with quote

Hi;

I started testing the cafepressbox class and added 2 more catogories

It works for the "wttw" (teddy bear) not for soswear:

as the following test script:
---------------------------------------------------------
<?php

include 'class.cafepressbox.php';
$cp = new cafePressBox;
$cp->setCacheDir('./cache');
$cp->setCacheTime(86400);
$cp->setCacheImages(true);

?>
<html>

<body>

<table border="0" width="100%" cellpadding="10">
<tr>
<td align="center">'amnuts' with link on</td>
<td align="center">'amnuts' with link off</td>
</tr>
<tr>
<td align="center">
<?php

$cp->setResizeCachedImages(75);
$cp->setStore('amnuts');
$cp->displayItem(true);

?>
</td>
<td align="center">
<?php

$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(false);

?>
</td>
</tr>
<tr>
<td align="center">'collingtons' with link on</td>
<td align="center">'collingtons' with link off</td>
</tr>
<tr>
<td align="center">
<?php

$cp->setResizeCachedImages(0);
$cp->setStore('collingtons');
$cp->setTemplate('<div style="width:250px;">[TXT]</div><br>[IMG]');
$cp->displayItem(true);

?>
</td>
<td align="center">
<?php

$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(false);

?>
</td>
</tr>
<?
/* Start ADJ =======================================
http://www.cafeshops.com/lightmotiv/145082
http://www.cafeshops.com/wttw
*/
?>

<tr>
<td align="center">'wttw' with link on</td>
<td align="center">'wttw' with link off</td>
</tr>
<tr>
<td align="center">
<?php

$cp->setResizeCachedImages(0);
$cp->setStore('wttw');
$cp->setTemplate('<div style="width:250px;">[TXT]</div><br>[IMG]');
$cp->displayItem(true);

?>
</td>
<td align="center">
<?php

$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(false);

?>
</td>
</tr>

<?
/* Start ADJ =======================================
http://www.cafeshops.com/soswearcom
*/
?>
<tr>
<td align="center">'soswearcom' with link on</td>
<td align="center">'soswearcom' with link off</td>
</tr>
<tr>
<td align="center">
<?php

$cp->setResizeCachedImages(0);
$cp->setStore('soswearcom');
$cp->setTemplate('<div style="width:250px;">[TXT]</div><br>[IMG]');
$cp->displayItem(true);

?>
</td>
<td align="center">
<?php

$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(false);

?>
</td>
</tr>

<? // END ADJ ======================================= // ?>

</table>

</body>

</html>

---------------------------------------------------------

Can you tell me where is the error I added or if it is a bug in cafepressbox script???

thks
Back to top
View user's profile Send private message
amnuts
Site Admin


Joined: 01 Sep 2002
Posts: 662
Location: East Sussex, England

PostPosted: Wed Feb 25, 2004 4:57 am    Post subject: Reply with quote

Hi,

There are a couple issues here...

Displaying a random product

I found that the 'array_rand' function was just returning exactly the same product id all the time. If you also found that the 'amnuts' or 'collingtons' products were always the same when you reloaded the page, then change this line (about line number 247):

Code:
$id = array_rand($this->products);


to this:

Code:
$keys = array_keys($this->products);
$id = $keys[rand(0, count($keys) - 1)];


Displaying products in a category

The pattern that is being looked for (set in the setPattern function) is all important. It is set up to look for links on the page that have this format:

Code:
<td align="center" valign="top"><p><a href="/wttw.8693069"><img class="imageborder" border="0" height="150" alt="Kook Target Teddy Bear" src="http://storetn.cafepress.com/9/8693069_F_store.jpg"></a><br><br><a href="/wttw.8693069">Kook Target Teddy Bear</a><br>$17.99</td>


but on that wttw page, as well as the soswearcom page, you have links in this format:

Code:
<td align="center" valign="top"><p><a href="/wttw/197539"><img alt="Are you a kook target" class="imageborder" border="0" src="http://logo.cafepress.com/9/19143.197539.jpg"></a></p><p><a href="/wttw/197539">Are you a kook target</a><br><span class="storesmallprint">Been cartooney'd lately?</span></p></td>


notice that the pattern is totally different. You can set a different pattern by passing the new pattern to the 'setPattern' function.

Andy
Back to top
View user's profile Send private message Send e-mail Visit poster's website AIM Address Yahoo Messenger MSN Messenger
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    php.amnuts.com Forum Index -> CafePress Box All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group