[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.

IC v5.0
Default DB


[query arrayref="discountref" sql="SELECT * FROM promotions
                  ORDER BY type,active_month"][/query]
   # 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,
         $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;


  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

  [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]
  <!-- END PREAMBLE -->
  [tmp page_title]Online Catalog | __COMPANY__[/tmp]
  [tmp members_only]1[/tmp]

  [control reset=1]
  [control reset=1]

  <!-- BEGIN CONTENT -->
        <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 
            <td colspan="4" class="text_subheading">[data table="cat" 
field="name" key="[item-field subcat]"]</td>
         <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>
                  <td width="40" valign="top" class="text_small">[page 
[item-code]]<img src="[if file 
width="35" border="0">[/page]</td>
                  <td width="78" valign="top" 
date][item-field date]<br>[/if-item-field][if-item-field 
format][item-field format]<br>[/if-item-field][if-item-field 
length]<br>[/if-item-field][item-price]<br><strong>&raquo; [page 
[item-code]]more info[/page]</strong></td>
              </table>[/then][else][page [item-code]]<img src="[if file 
width="118" height="118" border="0">[/page]<br>
              [if discount [item-code]]<b><font color="#FF0000">[scratch 
              &raquo;&nbsp;[page [item-code]]more 
info[/page]</b>[/else][/if]</td>[if value sub][then][if scratch 
item_counter == 4]
          <tr>[tmp item_counter][/tmp][/if][/then][else][item-alternate 4]
          <tr>[/item-alternate][/else][/if][/search-list][if value ti eq 
            <td align="right" colspan="4" 
class="text_small"><strong>&raquo;&nbsp;&nbsp;[page videos]View All 
          </tr>[/if][if value prodpath]
            <td align="right" colspan="4" 
class="text_small"><strong>&raquo;&nbsp;&nbsp;[page equipment]View Full 
          </tr>[/if]      </table>
  [value name=sub set=""]
  <!-- END CONTENT -->


Thomas J.M. Burton
Design & Production Director
Global Focus Digital Media, LLC

More information about the interchange-users mailing list