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.


Calendar Problem

 
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
evit
Newbie


Joined: 05 Nov 2004
Posts: 3

PostPosted: Mon Nov 08, 2004 9:54 pm    Post subject: Calendar Problem Reply with quote

Hey,
We just completed our 2005 calendar and I am attempting extract it like all the other merchandise...thus far we have only done apparel, this is the first non apparel item i'm trying to show randomly...for some reason it is telling me "no product found"...but the product is in the catagory I am feeding to the class. Do you konw of any problems relating to this. I plan on testing with more items very soon, just been really busy.
Thanks for your help in advance.
Brandon

For reference here are a few links...

http://www.cafepress.com/iue/407672 - the calendar catagory...

http://www.inuen.com/iue/test.php - the page I am trying to show the calendar on...

And the code that goes into test.php...as you can see with the echo statment the appropriate store catagory is being place where it should be...

Code:

$result = dbquery("SELECT * FROM ".$fusion_prefix."merchandise WHERE merch_front_page=1");
$data = dbarray($result);
$store_id = $data['merch_store'];
echo "$store_id";
opentable('Finished Project Merchandise');   
    $cp = new cafePressBox('iue',$store_id);
    $cp->displayItem(true);
closetable();
Back to top
View user's profile Send private message Visit poster's website
amnuts
Site Admin


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

PostPosted: Tue Nov 09, 2004 3:42 am    Post subject: Reply with quote

Hi, and welcome to the board!

It's not displaying the calendar because the regular expression is failing. In the class, the regular expression ends like this:

Code:
(.*?)<\\/a><br>\\$(\d+)\\.(\\d+)<\\/td>


Which means that after the link it's looking for '$8.30', or similar (basically a dollar sign followed by one or more digits, then a period, then one or more digits).

However, because the calendar has the sale tag on the end of it, the html looks like:

Code:
</a><br><font class="alertmessage"><b> Sale Price $17.99</b></font><img hspace=1 align=texttop src="/cp/img/saletag2.gif" width="41" height="15" alt="Sale" border="0"></td>


You have that font tag in there, the bold tag, then the 'Sale Price' text and an image.

What you have to do is use the setPattern method in the class to provide another regular expression. You can pretty much copy the one already in he class right up to the end where you'll need to compensate for the sale tag markup.

Andy
Back to top
View user's profile Send private message Send e-mail Visit poster's website AIM Address Yahoo Messenger MSN Messenger
evit
Newbie


Joined: 05 Nov 2004
Posts: 3

PostPosted: Tue Nov 09, 2004 4:07 pm    Post subject: Reply with quote

Hi Andy,
Thanks for the quick response. I understand what you're saying and will mess with it tonite. One question before I dig in and learn this aspect of PHP (as its new to me)...Once the sales tag goes away, will I have to change the code back to the original?
Thanks for your help.
Brandon
Back to top
View user's profile Send private message Visit poster's website
amnuts
Site Admin


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

PostPosted: Tue Nov 09, 2004 4:27 pm    Post subject: Reply with quote

That's right; but you don't actually need to alter the class. When you call the class in your script, just add a new line in with the setPattern method and the pattern you need to make it work. That way you only need comment out a line when the sale tag goes away. By commenting out your setPattern call you're setting the class to use its default pattern.

One easy way to manage this is by putting your regular expression into a file and calling that file in, something like:

$cp->setPattern(file_get_contents('sale.regexpr'));

That way you can tweak the pattern as many times as you like but not have to touch your code. Think of it like including an external style sheet in your html. Smile
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