[interchange-cvs] interchange - ton modified dist/foundation/templates/components/results_grid
interchange-core@icdevgroup.org
interchange-core@icdevgroup.org
Fri Dec 6 09:06:01 2002
User: ton
Date: 2002-12-06 14:05:26 GMT
Added: dist/foundation/templates/components results_grid
Log:
Added a new configurable results page component.
This results_grid component enables one to display
search results in a grid like fashion.
The layout of the product display is based on user
definable HTML templates. One default template is
provided.
Please send any comments or suggestions for improvement to:
Ton Verhagen (ton@verhagen.net).
Thanks!
Revision Changes Path
1.1 interchange/dist/foundation/templates/components/results_grid
rev 1.1, prev_rev 1.0
Index: results_grid
===================================================================
[comment]
ui_component: results_grid
ui_type: component
ui_name: results_grid
ui_class: content
ui_group: search
ui_help: Configurable results page with Buy List.
ui_label: Search Results (configurable grid) with Buy List
ui_source: templates/components/results_grid
cols:
label: Number of Columns to display?
options: 1,2,3*,4,5,6,7,8,9,10
type: select
help: You can control the number of rows by using an appropriate number for mv_matchlimit in the search
columnize:
label: Use Newspaper format?
widget: yesno
help: Set to Yes when you want your results vertically organized.
htmltmpl:
label: Template
widget: textarea_10_50
help: Define your own HTML template using {FIELDNAME} constructs as placeholders for the (record)fields. E.g. {SKU} for the SKU and {DESCRIPTION} for the description of a product. This will override the default template.
buylist_button:
label: Display Buy List Button?
widget: yesno
help: Only useful in combination with a Quantity box placeholder( {QUANTITY_BOX} ) in template.
[/comment]
<!-- BEGIN COMPONENT [control component results_grid] -->
[comment]
Available placeholders for HTML Template:
* All field names (in capitals) e.g. {SKU} for sku field, {COMMENT} for comment field, etc.
* Additional place holders:
{PRICE} - processed product field
{IMAGE} - processed product field, full image tag (item image)
{THUMB} - processed product field, full image tag (thumb image)
{STOCK} - Inventory check, returns text 'Yes' or link 'No' to stock-alert page
{PRODUCT_LINK} - Represents the URL to products page. To be used in href
{QUANTITY_BOX} - Text input box to specify the quantity of product
{BUY_BUTTON} - The 'BUY NOW' button
Please send any comments or suggestions for improvement to:
Ton Verhagen (ton@verhagen.net)
[/comment]
[tmp buylist_button][control buylist_button 0][/tmp]
<br>
[if scratch did_order]
[include file="templates/components/cart_display"]<br>
[/if]
[set did_order][/set]
[perl tables="products"]$Scratch->{itemcount}=0;return;[/perl]
[search-region]
[seti results_return_to][history-scan exclude=nothing count=0][/seti]
[set munge_quantity]
[calc]
$Scratch->{did_order} = 1;
@q = split /\0/, $CGI->{mv_order_quantity};
for (@q) {
next unless length $_;
$_ = "=$_";
}
@parms = grep /^mv_oi\d+/ && $CGI->{$_}, keys %{$CGI};
# If we have parms, means an individual buy. If we don't
# we want to strip empty items
unless (@parms) {
@i = split "\0", $CGI->{mv_order_item};
for(my $i = 0; $i < @i; $i++) {
next if length($q[$i]);
$i[$i] = '';
}
@i = grep length($_), @i;
@q = grep length($_), @q;
$CGI_array->{mv_order_quantity} = \@q;
$CGI->{mv_order_quantity} = join "\0", @q;
$CGI_array->{mv_order_item} = \@i;
$CGI->{mv_order_item} = join "\0", @i;
return;
}
my $item = $parms[0];
$item =~ /(\d+)/ or return;
my $idx = $1;
$idx--;
$CGI->{mv_order_item} = $CGI->{$item};
$CGI->{mv_order_quantity} = "$q[$idx]";
return;
[/calc]
[bounce href="[scratch results_return_to]"]
[/set]
[on-match]
<FORM ACTION="[area nothing]" METHOD=POST>
<INPUT TYPE=hidden NAME=mv_session_id value="[data session id]">
<INPUT TYPE=hidden NAME=mv_action VALUE=refresh>
<INPUT TYPE=hidden NAME=mv_separate_items VALUE=0>
<INPUT TYPE=hidden NAME=mv_click VALUE=munge_quantity>
[/on-match]
[calc]
my $n = [control cols 3];
$Scratch->{width_percent} = int(100 / $n) . '%' if $n > 0;
return;
[/calc]
[table-organize
embed=1
table='width="95%" border="0" cellspacing="0" cellpadding="3"'
cols='[control cols 3]'
columnize='[control columnize 0]'
]
[search-list]
[item-sub show_product]
my $sku = shift;
my $pdb = $Db{products};
my $record = $pdb->row_hash($sku);
return undef unless $record;
$Scratch->{itemcount}++;
### Definition of default template ###
#
my $tmpl = $Tag->control('htmltmpl') || <<EO_TMPL;
<div style="border: solid 1px #DDDDDD;" width="100%">
<table cellpadding=2 cellspacing=0 border=0 width="100%">
<tr class="contentbar1"><td colspan=2><b>{DESCRIPTION}</b></td></tr>
<tr>
<td><a href="{PRODUCT_LINK}">{THUMB}</a></td>
<td valign=top bgcolor="#eeeeee" width="100%">
<div style="padding-left:5px;">
<span style="font-size:10px;">
SKU: {SKU}<br><br>
Stock: {STOCK}<br>
</span>
<p align=right><a href="{PRODUCT_LINK}" style="text-decoration:none; font-size:10px;" title="Click here for more information on this product">More info...</a></p>
</div>
</td>
</tr>
<tr class="contentbar1"><td style="font-size:10px;">Price: {PRICE}</td><td align=right valign=middle>{QUANTITY_BOX} {BUY_BUTTON}</td></tr>
</table>
</div>
EO_TMPL
$record->{price} = $Tag->price($sku);
$record->{image} = $Tag->image({
imagesubdir => "items",
src => $record->{image},
extra => "border=0",
title => "Click for more information.",
alt => $record->{description},
});
$record->{thumb} = $Tag->image({
imagesubdir => "thumb",
src => $record->{thumb},
extra => "border=0",
title => "Click for more information.",
alt => $record->{description},
});
my $q = $Tag->data('inventory', 'quantity', $sku);
if ($q > 0) {
$record->{stock} = <<EOF;
<span style="color: #008000; font-size:10px; font-family: san-serif; font-weight: bold;">Yes</span>
EOF
}
else {
my $url = $Tag->area('stock-alert', $sku);
$record->{stock} = <<EOF;
<a href="$url" title="Click here to pre-order this item or get notified as soon as this item is available again." style="color: #FF0000; font-size:10px; font-family: san-serif; font-weight: bold;">No</a>
EOF
}
$record->{product_link} = $Tag->area($sku);
if ($Session->{browser} =~ /mac/) {
$record->{buy_button} = <<EOF;
<input type=submit value="[L]Buy now[/L]" onClick="this.form.mv_oi$Scratch->{itemcount}.value='$sku'" border=0>
EOF
}
else {
$record->{buy_button} = <<EOF;
<input type=image src="$Variable->{THEME_IMG_DIR}buynow.gif" onClick="this.form.mv_oi$Scratch->{itemcount}.value='$sku'" border=0>
EOF
}
$record->{quantity_box} = <<EOF;
<input type=text name=mv_order_quantity size=2 value="" style="height:16px;font-size:10px;background-color:#eeeeee;">
EOF
return $Tag->uc_attr_list($record,$tmpl);
[/item-sub]
<TD width="[scratch width_percent]">
<INPUT TYPE=hidden NAME="mv_order_item" VALUE="[item-code]">
<input type=hidden name="mv_oi[item-increment]" value="">
[item-exec show_product][item-code][/item-exec]
</TD>
[/search-list]
[/table-organize]
[on-match]
[if scratch buylist_button]<div align=right style="width:95%;"><br><INPUT TYPE=submit VALUE="Buy List"></div>[/if]
</FORM>
[/on-match]
[no-match]
<BR><BR>
<BLOCKQUOTE>
[comment]
Don't show the search string if it was empty, since it looks weird
and the user will see the error below anyway.
[/comment]
[tmp matchstring][value-extended name=mv_searchspec joiner=" | "][/tmp]
[if scratch matchstring]
Sorry, no matches for <B>[scratch matchstring]</B>.
[/if]
[if value mv_search_error]
<P>
<B>
Errors:
<BR>
[value-extended name=mv_search_error joiner="<BR>"]
</B>
[/if]
<BR><BR>
</BLOCKQUOTE>
[/no-match]
<BR CLEAR=LEFT>
[more-list]
<BLOCKQUOTE>
Matches [matches] of [match-count] found.
<BR>[more]<BR>
</BLOCKQUOTE>
[/more-list]
[/search-region]
<br>
<!-- END COMPONENT [control component results_grid] -->