Here's HOW to get S-Mart to show No Items Found

greenspun.com : LUSENET : S-Mart Shopping Cart : One Thread

Below is the part of the smart.cgi file that will make it show "No items found, click here to search again". In this message I included several lines of the EXISTING code before the place you'll add this part to the program and several lines of existing code AFTER where you will add it. I did this so that you would be able to find the right place in the script to insert it.

This "custom" code itself to make it show this only consists of 5 lines of code. I have notated these 5 lines that need to be added to the code by putting %'s in front of them. Just copy & paste these 5 lines with the %'s (but don't forget to take out hte %'s) into your code between the area shown above and the area shown below & you should be good to go.

Hope this explanation is easy enough to understand. P -Brad

Here's the code: ------------------------------------------------------------

elsif ($type eq 'search') { my($matches) = 0; my($i) = $pos; while (($matches < $numtolist) && ($i < $SIZE)) { if (index(lc $LINES[$i],lc $FORM{'search'}) >= 0) { $matches++; my(%ITEM); ($ITEM{'itemid'}, $ITEM{'name'}, $ITEM{'price'}, $ITEM{'descrip'}, $ITEM{'image'}, $ITEM{'weight'}, $ITEM{'itemurl'}, $ITEM{'group'}) = split(/\|/,$LINES[$i]); &print_item(\%ITEM); } $i++; } print "\n"; % if ($matches<1) { % print "

\n"; % print "
\n"; % } if ($i < $SIZE) { print "
\n"; print "\n"; print "\n"; print "
\n"; } } ------------------------------------------------ that's all there is to it & it will show No items found click here to search again

-Brad

-- Brad (bppilot@aol.com), April 24, 1998

Answers

Hi Brad, I would really like to use your patch but the message board script hacks up the script text and even made buttons. Could you possible email me the fix, hopefully the email prog won't hack it up too. maybe attach it as a text file.

Thanks in advance,

-- Marc Burnell (efxweb@efxweb.com), April 25, 1998.


Thanks for the tip Brad! You know another way to do this is, present the user with the "Not Found" message, and throw the seach box back up. Example ============================= if ($matches<1) { ##### start print "Sorry, no matches were found.

\n"; print ""; print "\n"; print "
\n"; print "
\n"; print "
"; } if ($i < $SIZE) { ##### end. ============================= - Dennis

-- Dennis List (eotd@gte.net), November 12, 1998.

Thanks Dennis - That's a good idea. For my use I've got my "search" box in my footer.html file which is displayed at the bottom of every screen so I don't need to use the code within the program to bring up the search box. Thanks for the suggestion though - I'm sure that there will be others who will definately benefit from you help.

Thanks again!

-BP

-- BP (bppilot@aol.com), November 12, 1998.


Moderation questions? read the FAQ