[ic] How to use 'if' to compare item-field inside an item-list?

Ed LaFrance interchange-users@lists.akopia.com
Tue Jun 5 12:06:01 2001


At 10:40 AM 06/05/2001 +0100, you wrote:
> > > Can anyone help me. I'm confused about the 'if' tag. I want to modify
>the
> > > receipt.html page to allow for provisioning of subscription services,
> > > something different to soft downloads. I tried it like below, but the
>listed
> > > item doesn't pass my test. I looked at the documentation on the 'if'
>tag,
> > > and it doesn't list item-field as a type, but then I can't seem to
>figure
> > > out what would be the right type in this case (value doesn't work). All
>the
> > > examples I've seen only seem to test that a value is not empty, which is
>not
> > > what I want here. The tag [item-field dl_type] does return the correct
> > > value, by the way. Please, I'm wracking my brain to pieces!
> > >
> > Use [if-item-field dl_type] instead of [if item-field dl_type], that extra
> > dash is important.
>
>Thanks Jason. Unfortunately, I tried that and it didn't work. The docs say
>the [if-item-field] is a simple test of whether or not the field is empty.
>No ability to place a condition. Also, there is no elsif contruct. Here's my
>take: we're in a loop, there must be a reference to the current item in
>order for things like the [if-item-field] to work. How can I test a field
>value with a condition? I shouldn't need to use [if data table::field::key]
>because we have a reference to the item, and this code is not even aware of
>the table it is in (one of the specified product tables). I will if that's
>what it takes, but I think it's a bit weak. I can echo the value with
>[item-field dl_type], so I ought to be able to do a compare on it. Or maybe
>I should use a scratch variable... [set somevar][item_field dl_type][/set]
>[if scratch somevar =~ /pattern/]...?

Exacerbating this whole issue somewhat is the unpleasant fact that IC [if's 
and [if-prefix's are not exactly rockets in terms of performance.  I have 
learned that hard way many times, that if a series of tests needs to 
performed repeatedly in a list of results, you will gain much better 
performance with a [calc] or [perl] block, or better yet, a usertag.  It is 
easy for these things to balloon into thousands of conditional evaluations 
in one screenful of search results or cart contents, and if you don't do 
the work to break free of the [if family, you are really going to feel the 
drag.

- Ed L.


> > > ------------------------------^snip------------------------------
> > > [item-list]
> > >         [if-item-field download]
> > >                 [if !value fax_order]
> > >                         [if item-field dl_type =~ /^serv/i]
> > >                         [comment]This is a provisioned service[/comment]
> > >                         This is a provisioned service.
> > >                         [elsif item-field dl_type =~ /^soft/i]
> > >                         [comment]This is a soft goods download[/comment]
> > >                         This is a soft goods download.
> > >                         [set download_present]1[/set]
> > >                         [userdb
> > >                                         function=set_file_acl
> > >                                         mode="expire 7 days"
> > >                                         location="[either][item-field
> > > dl_location][or][item-code][/either
> > > ]"
> > >                         ]
> > >                         [/elsif]
> > >                         [else]
> > >                         [comment]Unknown type[/comment]
> > >                         Unknown type: [item-field dl_type]
> > >                         [/else]
> > >                         [/if]
> > >                 [/if]
> > >         [/if-item-field]
> > > [/item-list]
> > > ------------------------------^snip------------------------------
> > >
> > > Thanks
> > > -Matt
>
>
>_______________________________________________
>Interchange-users mailing list
>Interchange-users@lists.akopia.com
>http://lists.akopia.com/mailman/listinfo/interchange-users

===============================================================
New Media E.M.S.               Software Solutions for Business
463 Main St., Suite D          eCommerce | Consulting | Hosting
Placerville, CA  95667         edl@newmediaems.com
(530) 622-9421                 http://www.newmediaems.com
(866) 519-4680 Toll-Free       (530) 622-9426 Fax
===============================================================