[Date Prev][Date Next][Thread Prev][Thread Next][Minivend by date
][Minivend by thread
]
[mv] Dynamic Generation of Clickbars: Solution
****** message to minivend-users from Chris Rapier <rapier@psc.edu> ******
So I solved my own question :)
The following nugget of code will allow you to generate a clickbar based
on the contents of a database field. The database I'm using for this is
catopts and has the following format:
catname title title_image subcats
Baby_Food Baby Food dummytitle.jpg
Cereals,Jars,Juice,Snacks
Baking_Supplies Baking Supplies dummytitle.jpg Flour,Mixes
...
If the value sucked out of mv_searchspec doesn't match a row's name (the
key) then it sets things to a default and skips the perl bit. This
allows me to use the same results page for user searches as well as
searches I've defined.
I'm convinced that this is *not* the best way to do this. My feeling is
that there is a much cleaner way of handling it but I can't think of one
at the moment. If anyone has any improvements please let me know.
[comment]
cjr: june 27,2000
generates clickbars based on subcategory names existing in a database
field
assumption: 1st entry in mv_searchspec array is the major category
field value if it doesn't correspond to a major category field value
then its a user defined search spanning multiple categories
subcat_clickbar: html code for the click bar
note: subcategory names have to correspond to the image file names.
category_name: The 1st entry in mv_searchspec
category_title: The title of the category based on table lookup
titleimage: The image used for the page header
usage: embed in begining of page. use [scratch subcat_clickbar] to
display the resultant html.
[/comment]
[perl]
$Scratch->{'category_name'} = $Values->{'mv_searchspec'}[0];
return "";
[/perl]
[seti category_title][data base="catopts" field ="title" key="[scratch
category_name]"][/seti]
[if !scratch category_title]
[set category_title]Your Search[/set]
[set titleimage]yrsearchtitle.jpg[/set]
[set perlflag]1[/set]
[else]
[seti titleimage][data base="catopts" field ="title_image"
key="[scratch category_name]"][/seti]
[perl catopts]
$Scratch->{'subcat_clickbar'} = "";
my $ref = $Db{'catopts'};
my $vendurl = $Config->{'VendURL'};
my $colname="subcats";
my $build_html = "";
my $rowname= $Values->{'mv_searchspec'}[0];
my $searches = $ref->field($rowname, $colname);
my @subcats = split /\,/, $searches;
foreach (@subcats) {
$Scratch->{'subcat_clickbar'} .= "<a
href=\"$vendurl/scan/sf=category,subcat,category2,subcat2/se=$rowname/se=$_/os=no/ml=5.htm\
l/tf=description,brand\"><img src =
\"/windfallfoods/images/$_.gif\"></a>\n";
}
return "";
[/perl]
[/else]
[/if]
-
To unsubscribe from the list, DO NOT REPLY to this message. Instead, send
email with 'UNSUBSCRIBE minivend-users' in the body to Majordomo@minivend.com.
Archive of past messages: http://www.minivend.com/minivend/minivend-list