[ic] Still Not Working - HELP: [if discount [item-code]] interpolation trouble
Thomas J.M. Burton
interchange-users@interchange.redhat.com
Wed Jan 30 16:02:01 2002
----- Original Message -----
From: "Mike Heins" <mheins@redhat.com>
> First of all, I cannot conceive of a situation where you would
> want [search-region interpolate=1]. Of course it works fine
> if you turn it off -- that is how it should be used.
...
> Third, no one will ever be able to help with snippets of page
> code out of context. Give some reasonably-clipped complete
> example.
Well, that's the solution I came to for what I'm building. The source code
below should put it into context. I tried to include a full copy of the
source code when first posting my question, but my e-mail was rejected
because it looked like HTML e-mail.
Here's some notes for context a slightly edited version of my code:
NOTES
1. The code below is from a search results page I'm building. [value cat] is set
in the search form that posts to the results page.
2. I have a categories datatable set up to control various elements relating
each product category. Fields are as follows:
code unique id for category
label category name, used for display in catalog pages
search_fields comma-separated list of fields that category can be searched by
desc_segments comma-separated list of fields that make up a product's description
sortby comma-separated list of fields to sort searches within this category by
display_page designates which template this category is displayed using
3. I set interpolate=1 in the search-region for a couple of reasons:
A) I have code for the [more-list] section in a separate template file since I will be using
it in a few different results pages. The [more-list] tags are not interpolated if I don't have
interpolation=1 in [search-region]. I realize there's probably a better way of doing this.
B) The main reason. Within the search-list, I have a loop that expands the values from
the desc_segments field in the categories table into [item-param] tags, like so:
desc_segments value: size,color,shape
expands to: [item-param size] [item-param color] [item-param shape]
Without setting interpolate=1 in the search-region, the tags created by the loop are not
interpolated. If there is a better way of doing this, please show me.
4. Getting this to work is my primary concern. I'm aware that there are probably more
efficient ways to do this, and I would greatly appreciate guidance with any portion of the
code. I also realize that interpolate=1 should be avoided. I didn't see any other way to do what
I was doing.
SOURCE CODE
[query list=1 sql="SELECT * FROM categories WHERE code='[value cat]'" prefix=catinfo list_prefix=catinfo]
[catinfo]
[search-region interpolate=1]
[include file="templates/components/more_thin"]
<table width="520" cellpadding="0" cellspacing="0" border="0">
[search-list]
[on-change sub][condition][loop list=[catinfo-param sortby] ml=1][item-param [loop-code]][/loop][/condition]
<tr>
<td colspan="6"><img src="/interface/images/spacer.gif" height="20" width="1"></td>
</tr>
<tr bgcolor="#000000">
<td class="smallLinkWhiteBold" height="20" colspan="6" align="left">
[loop list=[catinfo-param sortby] ml=1][item-param [loop-code]][/loop]
</td>
</tr>
<tr bgcolor="#333366">
<td class="smallLinkWhiteBold" width="340" height="20" colspan="2"> Photo/Description</td>
<td class="smallLinkWhiteBold" width="60">Sold By</td>
<td class="smallLinkWhiteBold" width="50">Price</td>
<td class="smallLinkWhiteBold" width="30">Qty.</td>
<td class="smallLinkWhiteBold" width="40"> </td>
</tr>
[/on-change sub]
<!-- BEGIN DISCOUNT CODE -->
[query list=1
prefix=disc
list_prefix=discInfo
sql="SELECT * FROM discounts
WHERE product = '[value cat]'
AND month = '[tag time]%m[/tag]'
AND start <= '[tag time]%e[/tag]'
AND end >= '[tag time]%e[/tag]'"]
[discInfo]
[discount interpolate=1 code="[item-param code]"] $s * (1 - ( [disc-param amount] / 100 ))[/discount]
[disc-param product] [disc-param amount]
[/discInfo]
[no-match]
[discount [item-param code]][/discount]
[/no-match]
[/query]
<!-- END DISCOUNT CODE --->
<tr bgcolor="#333366">
<td colspan="6" align="right"><img src="/interface/images/spacer.gif" height="1" width="1"></td>
</tr>
<tr>
<td colspan="6" class="smallTextWhite">
</td>
</tr>
<tr bgcolor="[item-alternate 2]#9999CC[else]#CCCCFF[/else][/item-alternate]">
<td width="75"><img src="/products/photos/[item-param code].jpg"></td>
<td class="smallTextBlack" width="265">
[loop arg="[catinfo-param desc_segments]"][item-param [loop-code]] [/loop]
<input type="hidden" name="[item-param code]_cat" value="[catinfo-param code]">
<input type="hidden" name="[item-param code]_cat_label" value="[catinfo-param label]">
<input type="hidden"
name="[item-param code]_description"
value="[loop arg="[catinfo-param desc_segments]"][item-param [loop-code]] [/loop]">
</td>
<td class="smallTextBlack" width="60" align="center">[item-param soldby] of [item-param qty]</td>
<td class="smallTextBlack" width="50" align="right">
[if type=discount term="[item-param code]"]
$[item-param price] <br>
<s>$[item-param price]</s>
[else]
$[item-param price]
[/else]
[/if]
</td>
<td width="30" align="center">
<input size="2" name=mv_order_quantity value="">
<input type=hidden name=mv_order_item value="[item-code]"></td>
<td class="smallTextBlack" width="40" align="center" bgcolor="#666699">
<input type="image"
src="/interface/images/button_order.gif"
value="ORDER NOW"
width="32"
height="26"
border="0">
</td>
</tr>
<tr bgcolor="#333366">
<td class="smallLinkWhiteBold" colspan="6" align="right">
<img src="/interface/images/spacer.gif" height="1" width="1">
</td>
</tr>
<tr>
<td colspan="6" align="right"><img src="/interface/images/spacer.gif" height="4" width="1"></td>
</tr>
[/search-list]
</table>
[/search-region]
</form>
[/catinfo]
[/query]