[ic] search-region/query conflict?
Thomas J.M. Burton
tom at globalfocusdm.com
Wed Jun 16 20:59:36 EDT 2004
Hi IC Users,
I have the following query and perl code (work in progress) in a file
that I'm including in my page template regions. The perl code is
executed completely in all pages except results.html.
As far as I can tell, there's some kind of conflict between the
query/perl and the search-region in the results page. If I include the
code at the bottom of the page (after the search-region tags), it works.
But it breaks if included at the top (before the search-region tags)
where it needs to be in order to do what I want it to do.
Any ideas? Any other improvements to the perl code are welcome too.
USING
IC v5.0
Default DB
CODE IN INCLUDED FILE:
[query arrayref="discountref" sql="SELECT * FROM promotions
ORDER BY type,active_month"][/query]
[perl]
# Initialize output variable
my $out = '';
# Assign current month to variable
my $cmonth = $Tag->time({locale => en_US,},"%m");
# Get the query results, has multiple fields
my $ary = $Tmp->{discountref};
foreach $line (@$ary) {
my ($code,
$type,
$active_month,
$timed,
$start_date,
$end_date,
$use_year,
$discount_skus,
$discount_type,
$discount_amount,
$dep_1,
$dep_op_1,
$dep_val_1,
$dep_2,
$dep_op_2,
$dep_val_2,
$dep_3,
$dep_op_3,
$dep_val_3,
$dep_4,
$dep_op_4,
$dep_val_4,
$description_1,
$url,
$link_text,
$description_2,
$teaser_text,
$cart_text) = @$line;
# Format discount amount for display and calculations
my $dcalc = '';
my $ddisp = '';
if($discount_type == 1) {
$dcalc.= ' * ';
$dcalc.= 1 - ( $discount_amount / 100 );
$ddisp.= "$discount_amount%";
}
# Test type of promotion
if($type == 1 && $active_month == $cmonth) {
$out.= "POTM: $code $active_month $description_1\n";
my @skus = split/,/, $discount_skus;
my $disc = '$s';
$disc.= $dcalc_op;
$disc.= $dcalc;
for(@skus) {
$Tag->discount({code => $_,},'');
$Tag->discount({code => $_,}, $disc);
my $dnote = "$ddisp off this month!";
$Tag->tmp({name => "disc_note$_",}, $dnote);
$out.= " Discount $_ $disc\n";
}
}
if($type == 2) {
$out.= "COMB: $code $description_1\n";
}
}
return $out;
[/perl]
RESULTS.HTML CONTAINS*:
[comment]
ui_page: results.html
ui_type: page
ui_name: results.html
ui_page_template: leftonly
ui_version: 5.0.0
ui_source: pages/results.html
ui_template: yes
ui_template_name: standard
[/comment]
<!-- BEGIN PREAMBLE -->
[search-region]
[tmp section_code][either][value ti][or][value-extended
name=mv_searchspec index=1][/either][/tmp]
[tmp page_sub_title][if value prodpath eq "sport"]Top Picks for [data
table=sports field=label code="[value-extended name=mv_searchspec
index=0]"][elsif value prodpath eq "goal"]Top Picks for [data
table=training_goals field=label code="[value-extended
name=mv_searchspec index=0]"][/elsif][elsif value promo eq
"1"][time]%B[/time] Product of the Month[/elsif][else][/else][/if][/tmp]
[/search-region]
<!-- END PREAMBLE -->
[tmp page_title]Online Catalog | __COMPANY__[/tmp]
[tmp members_only]1[/tmp]
[control reset=1]
[control-set]
[component][/component]
[/control-set]
[control-set]
[component][/component]
[/control-set]
[control-set]
[component][/component]
[/control-set]
[control-set]
[component][/component]
[/control-set]
[control-set]
[component][/component]
[/control-set]
[control-set]
[component][/component]
[/control-set]
[control-set]
[component][/component]
[/control-set]
[control-set]
[component][/component]
[/control-set]
[control-set]
[component][/component]
[/control-set]
[control-set]
[component][/component]
[/control-set]
[control reset=1]
@_LEFTONLY_TOP_@
<!-- BEGIN CONTENT -->
[search-region]
[more-list][more][/more-list]
<table width="570" border="0" cellspacing="20" cellpadding="0">
<tr>[search-list][if value sub][then][on-change
sub][condition][item-field subcat][/condition][if !scratch
item_counter][elsif scratch item_counter != 4]
<td colspan="[calc]4 - [scratch
item_counter][/calc]"> </td>
</tr>
<tr>[/elsif][/if]
<td colspan="4" class="text_subheading">[data table="cat"
field="name" key="[item-field subcat]"]</td>
</tr>
<tr>[tmp item_counter][/tmp][/on-change sub][/then][/if][tmp
item_counter][calc][scratch item_counter] + 1[/calc][/tmp]
<td width="118" valign="top" align="center"
class="text_small">[if explicit][condition] [item-field category] eq
"books" | [item-field category] eq "videos" [/condition][then]<table>
<tr>
<td width="40" valign="top" class="text_small">[page
[item-code]]<img src="[if file
__DOCROOT__/images/products/small/[item-code].jpg]/images/products/small/[item-code].jpg[else]/interface/pixel_spacers/FFFFFF.gif[/else][/if]"
width="35" border="0">[/page]</td>
<td width="78" valign="top"
class="text_small"><strong>[item-description]<br></strong>[if-item-field
date][item-field date]<br>[/if-item-field][if-item-field
format][item-field format]<br>[/if-item-field][if-item-field
length][item-field
length]<br>[/if-item-field][item-price]<br><strong>» [page
[item-code]]more info[/page]</strong></td>
</tr>
</table>[/then][else][page [item-code]]<img src="[if file
__DOCROOT__/images/products/small/[item-code].jpg]/images/products/small/[item-code].jpg[else]/interface/pixel_spacers/FFFFFF.gif[/else][/if]"
width="118" height="118" border="0">[/page]<br>
[if discount [item-code]]<b><font color="#FF0000">[scratch
name="disc_note[item-code]"]</font></b><br>[/if]
<b>[item-description]<br>
» [page [item-code]]more
info[/page]</b>[/else][/if]</td>[if value sub][then][if scratch
item_counter == 4]
</tr>
<tr>[tmp item_counter][/tmp][/if][/then][else][item-alternate 4]
</tr>
<tr>[/item-alternate][/else][/if][/search-list][if value ti eq
"instruction"]
<tr>
<td align="right" colspan="4"
class="text_small"><strong>» [page videos]View All
Videos[/page]</strong></td>
</tr>[/if][if value prodpath]
<tr>
<td align="right" colspan="4"
class="text_small"><strong>» [page equipment]View Full
Catalog[/page]</strong></td>
</tr>[/if] </table>
[/search-region]
[value name=sub set=""]
<!-- END CONTENT -->
@_LEFTONLY_BOTTOM_@
Thanks,
Tom
--
________________________________________
Thomas J.M. Burton
Design & Production Director
Global Focus Digital Media, LLC
www.globalfocusdm.com
More information about the interchange-users
mailing list