Developer forum

Forum » Templates » Nested if-statements

Nested if-statements

Anders Ørsted-Olsen
Reply
 
Hi,

Maybe this is a noob error...

I'm building a news list and want to check for content in News:Text and News:Link. If there are no content in Text (news text) OR Link (pdf), then no <a href=""> will be added.

This is my lastest template:
<!--@If(News:Text!='')-->
                
    <!--@If(News:Link!='')-->
        <strong><!--@News:Heading--></strong><br>
        <!--@News:Date.LongDate--> <!--@News:Manchet--><!--@News:FirstXChar-->
    <!--@EndIf-->
    <!--@If(News:Link='')-->
        <a id="news<!--@News:ID-->" href="<!--@News:Href-->" <!--@News:LinkPopup-->>
            <strong><!--@News:Heading--></strong><br>
            <!--@News:Date.LongDate-->
        </a>
    <!--@EndIf-->

<!--@EndIf-->


<!--@If(News:Link!='')-->
                
    <!--@If(News:Text!='')-->
        <strong><!--@News:Heading--></strong><br>
        <!--@News:Date.LongDate--> <!--@News:Manchet--><!--@News:FirstXChar-->
    <!--@EndIf-->
    <!--@If(News:Text='')-->
        <a id="news<!--@News:ID-->" href="<!--@News:Href-->" <!--@News:LinkPopup-->>
            <strong><!--@News:Heading--></strong><br>
            <!--@News:Date.LongDate-->
        </a>
    <!--@EndIf-->

<!--@EndIf-->

With this template, news items without Text or Link are not printed.

I'm considering converting the template to XSLT but I think it should be possible with DW tags.

Anyone?

Regards,
Anders

Replies

 
Vladimir
Reply
Hi Anders!

Try please to use ==
    <!--@If(News:Link=='')-->
        <!--@If(News:Text=='')-->

Best regards,
Vladimir

 
Nicolai Høeg Pedersen
Reply
@Vladimir - he can use both: http://templates.dynamicweb-cms.com/TemplateTags/Dynamicweb-template-tags/General-tags/If-statements.aspx

@Anders. If you have a news item with no text or a link, neither If(News:Text!='') or If(News:Link!='') will be true so nothing will be printed... That makes perfect sense with the statements you made.

You then have to do something like

If(News:Text='')
If(News:Link='')
****Print out news items withouthem
endif
endif
 


 

You must be logged in to post in the forum