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

Matt Flaherty interchange-users@lists.akopia.com
Tue Jun 5 05:36:01 2001


> > 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/]...?

> > ------------------------------^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