Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
THRUST SERVICES & TOOLS
CLOUD EDITIONS
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Web CMS (TeamSite)
Help with IF/OR statement
iwcnb
I am trying to write an IF statement in the presentation template that look at the DCR field called "Link" and output the data from the DCR.
This is what I am trying to do in pseudo code:
IF dcr.Link IS NOT empty OR NOT EQUAL "^http://" (Regex matching the exact pattern at the beginning of the string)
THEN
Display the dcr.Link data
ENDIF
I have coded like this but I could not get this to work.
<iw_if (expn="{iw_value name='dcr.Link'/}" ne ''" || expn="{iw_value name='dcr.Link'/}" ne ''^http://")>
<iw_then><![CDATA[<a href='<iw_value name='dcr.Link'/>'>Click Here</a><br>]]></iw_then>
</iw_if>
Could you please help me with this and what did I do wrong?
Help is much appreciated!
Find more posts tagged with
Comments
james1
That is not valid XML. It also isn't a valid regex test.
Try something like this:
<iw_if expn="( {iw_value ... /} ne "") || ( {iw_value ... /} !~ /^http:\/\/)">
-- James
--
James H Koh
Interwoven Engineering
iwcnb
James,
I have tried your suggestion but I still get the error.
<iw_if expn="( {iw_value name='dcr.Link' /} ne "") || ( {iw_value name='dcr.Link' /} !~ /^http:\/\/)">
AND
<iw_if expn="( {iw_value name="dcr.Link" /} ne "") || ( {iw_value name="dcr.Link" /} !~ /^http:\/\/)">
What would be wrong here?
XMLCrossRef.dcpackage.zip
Migrateduser
Can you narrow it down by testing only one at a time to see which one is failing?
I'm kind of skeptical about {iw_value name="dcr.Link" /} !~ /^http:\/\/)
because I'm not sure about the significance of !~ over ne in this case.
Thanks
iwcnb
I have tried both cases but I still get the error.
MattP
I can think of 2 things that MAY be incorrect. What version are you using? On 5.5.2 the syntax for an expression is "expr" you are using "expn". As well, I think the quotes are incorrect, essentially, you are ending your expression at ne "
<iw_if expn="( {iw_value name='dcr.Link' /} ne "") || ( {iw_value name='dcr.Link' /} !~ /^http:\/\/)">
<iw_if expr="{iw_value name='dcr.Link'/} ne ''"> (that is ne singlequote, singlequote, doublequote)
What is the check for http:// for? Can you handle the validation on the template with formAPI? What this statement is saying is "if I am not an empty string OR I begin with http://". What is it your are trying to achieve? An "or" statement should be formatted:
<iw_if expr="{iw_value name='dcr.whatever'/} eq 'whatever' || {iw_value name='dcr.whatever'/} eq 'whatever'">
Your statement may have too many (), but maybe you are using a different version.
Does this help?
Matt
Matthew Petitjean
BOC Group
Murray Hill, NJ 07974 USA
Error.docx
iwcnb
I am using 5.5.2 and I have changed the expression to "expr".
DCR.Link data is a path to a file, it can be absolute or relative. If the path is relative starting "/news/" then I like to execute the IF statement. I think I have tried the harder way of writting the logic that I want.
Can I use something like this?
<iw_if expn="({iw_value name='dcr.Link' /} !~ /^\/news\/)">
-iwcnb
MattP
Try this. Really, you shouldn't need to check for a missing value because that should be handled in the form. Anyway....
<iw_if expr="{iw_value name='dcr.Link'/} ne '' ">
<iw_then>
<!--If there is a value, see if it starts with http (leave out the
/ incase of https) -->
<iw_if expr="{iw_value name='dcr.Link'/} =~ /^http/">
<iw_then>
<!--link has http do what you want here-->
</iw_then>
</iw_if>
<iw_else>
<!-- the value is either blank or doesn't begin with http-->
<!--link does not have http do what you want here-->
</iw_else>
</iw_then>
</iw_if>
Let me know if this works.
Matt
Matthew Petitjean
BOC Group
Murray Hill, NJ 07974 USA