Results 1 to 7 of 7
  1. #1
    Newbie
    Join Date
    September 28th, 2005
    Posts
    20
    Nested IF statements -why don't they work?
    Hi everyone

    I have this code in my index page. But it won't work. It's the nested IF statements that cause it to go haywire. Anyone know why? I have also tried multiple criteria but without any meaningful result. Thanks. Phillip

    <ul>

    [WM-Record]
    [WM-If: Field: status <> 6]
    <li>[WM-Field: Project_title]. HTA Ref: [WM-Field: Reference nolink]. Research Type:
    ([WM-Field: ResearchTypeDesc nolink]).
    [WM-If: Field: PubDateDesc <> ""]
    Estimated publication date: [WM-Field: PubDateDesc nolink]
    [/WM-If]
    <br />

    <br />
    </li>
    [/WM-If]
    [/WM-Record]

    </ul>

  2. #2
    Affiliate Manager
    Join Date
    January 18th, 2005
    Location
    Los Angeles, California
    Posts
    1,913
    Nested IFs are not currently supported in WebMerge (though I intend to add that in v3). However it does support multiple IF expressions, and in most cases that satisfies what's needed. Will that work for what you need to do?
    Richard Gaskin
    Developer of WebMerge: Publish any data feed on any site
    http://www.fourthworld.com

  3. #3
    Newbie
    Join Date
    March 8th, 2005
    Posts
    11
    Just to add to Richard's reply, multiple ifs do get a bit messy, but it's possible to do everything normal humans should require. Make sure you have the latest version of WM - there were some bugs in this before, but it all works nicely now )

    Your code could be:

    <ul>
    [WM-Record]

    [WM-If: Field: status <> 6]
    <li>
    [WM-Field: Project_title].
    HTA Ref: [WM-Field: Reference nolink].
    Research Type: ([WM-Field: ResearchTypeDesc nolink]).
    [/WM-If]

    [WM-If: (Field: PubDateDesc <> "") AND (Field: status <> 6)]
    Estimated publication date: [WM-Field: PubDateDesc nolink]
    [/WM-If]

    [WM-If: Field: status <> 6]
    <br /><br />
    </li>
    [/WM-If]

    [/WM-Record]
    </ul>

  4. #4
    Newbie
    Join Date
    September 28th, 2005
    Posts
    20
    Nested IF statements work around
    Just got back from hols so have just seen this posting. Thanks, Seastwood, for your advice. This has done the trick!

  5. #5
    Newbie
    Join Date
    September 28th, 2005
    Posts
    20
    Problem with IF fields using ELSE
    I spoke too soon. The ELSE statement in the code (see below) is causing the records that don't meet the ELSE condition to break out of the html code for the listing and appear in a huge bundle at the top of the page (see http://www.hta.ac.uk/project/index2.asp). Where the condition is met for the few records at the bottom of the listing then that works OK.

    If I remove the line containing the ELSE condition then the page works fine.

    Any idea what I am doing wrong - or is there a problem with WebMerge?

    Thanks


    Phillip

    Code follows:


    <ul>
    [WM-Record]
    [WM-If: Field: status <> 6]
    <li>
    [WM-Field: Project_title].
    HTA Ref: [WM-Field: Reference nolink].
    Research Type: [WM-Field: ResearchTypeDesc nolink].
    [/WM-If]

    [WM-If: (Field: PubDateWebEstSort <> 20990909) AND (Field: status <> 6)]
    Estimated publication date: [WM-Field: PubDateDesc nolink]
    [WM-Else]No publication required.
    [/WM-If]

    [WM-If: Field: status <> 6]
    <br />
    <br />
    </li>
    [/WM-If]

    [/WM-Record]

    </ul>

  6. #6
    Newbie
    Join Date
    March 8th, 2005
    Posts
    11
    Phillip,

    I've had a look at your code but obviously I don't have your data set.

    When you look at the conditions, the logic doesn't quite work out:

    I assume there are some records in the data set where status=6 that you don't want printed now.

    The second If statement basically says this:

    IF status is not 6 AND pubdateweb is not 2099
    THEN write the pubdate.

    However, when it comes to ELSE, it's not only those items whose pubdate is not 2099 that don't match the criteria - all the records whose status = 6 will also produce "No publication required".

    I guess you have a sort in place that has put all those records at the top.

    Solution:

    Rather than the Else statement, use another If:

    [WM-If: (Field: PubDateWebEstSort <> 20990909) AND (Field: status <> 6)]
    Estimated publication date: [WM-Field: PubDateDesc nolink]
    [/WM-If]

    [WM-If: (Field: PubDateWebEstSort = 20990909) AND (Field: status <> 6)]
    No publication required.
    [/WM-If]


    Hope that helps, it's good to see other WM users who aren't building generic web shops! (no offence

    Simon

  7. #7
    Newbie
    Join Date
    September 28th, 2005
    Posts
    20
    IF statements
    Hello there

    Thanks for your advice. In the end I just removed the ELSE condition and added another IF condition as you suggested but made it a simpler one as follows and it now seems to work.

    [WM-If: Field: PubDateWebEstSort = 20990909]
    No publication required.
    [/WM-If]


    Phillip

  8. Newsletter Signup

+ Reply to Thread

Similar Threads

  1. CJ links don't work
    By Wes Nathan in forum Commission Junction - CJ
    Replies: 12
    Last Post: October 7th, 2010, 08:09 AM
  2. Should I work with networks I don't like?
    By markwelch in forum Midnight Cafe'
    Replies: 28
    Last Post: July 15th, 2008, 10:45 AM
  3. Replies: 0
    Last Post: July 9th, 2006, 05:01 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •