[ic] if tag weird behavior
Ton Verhagen
tverhagen at alamerce.nl
Sun Oct 28 14:35:45 EST 2007
Quoting Mike Heins <mike at perusion.com> :
>Quoting Ton Verhagen (tverhagen at alamerce.nl):
> > Dear All,
> >
> > I noticed the following 'weird' behavior of the if tag.
> >
> > Examine the following code:
> >
> > [tmp test_value]00000036[/tmp]
> >
> > [if type=explicit condition="[scratch test_value]"]
> > Value is: [scratch test_value]
> > [else]
> > No value
> > [/else]
> > [/if]
> >
> > Result:
> > Value is: 00000036
> >
> > So far so good.
> >
> > Now set the tmp to another (special ?) value:
> >
> > [tmp test_value]00000159[/tmp]
> > ..... if-code as above
> >
> >
> > Result:
> > No value
> >
> >
> > When I change the above code to the following, everything works
> as expected.
> >
> > [if type=explicit condition="[scratch test_value]"]
> > [condition]
> > return 1 if $Scratch->{test_value};
> > return 0;
> > [/condition]
> > Value is: [scratch test_value]
> > [else]
> > No value
> > [/else]
> > [/if]
> >
> >
> > This behavior can be duplicated in the online demo (test code in admin
> > section)
> >
> > Any ideas?
>
>Explicit is intended to have valid code as it's test, and a literal like
>that has undetermined behavior when interpreted as Perl code.
>
>Why you would do that instead of:
>
> [if scratch test_value]
> foo
> [/if]
Because I simplified the code a bit.
I am actually testing if a control of a component contains a value or not.
And as far as I am aware of, there is no [if control test_value]
available in IC.
I had something like below in a modified random component:
[loop serach=|
fi=products
st=db
[if type=explicit condition="[control brand]"]
sf=brand
se=[control brand]
op=eq
[else]
ra=yes
[/else]
[/if]
|]
do something
[/loop]
Everything seemed to work well until we discovered that for
brand=00000159 no proper results were returned.
Best regards,
Ton
--
Alamerce Nederland --- Cornerstone of eBusiness
Phone +31-40-2374381 info at alamerce.nl http://www.alamerce.nl
eCommerce Solutions -- Consulting -- Website & Interchange Hosting
More information about the interchange-users
mailing list