• Resolved RalfM

    (@ralfm)


    Hi,
    within a loop I want to compare if the last loop had the same value in a custom field like the actual loop.
    I was able to set a variable like this within the [else]:

    [set postleitzahl][field zip][/set]
    neue PLZ: [get postleitzahl] 

    But to compare the actual zip value with the variable don’t work. This is what I tried last:

     
    [if field=zip value='postleitzahl']
    [if field=zip value={postleitzahl}]
    [if field=zip value=[pass vars]{postleitzahl}[/pass]]

    I hope you guys can give me a hint how to compare field value and variable.
    Thanks.

    • This topic was modified 7 years, 11 months ago by RalfM.
    • This topic was modified 7 years, 11 months ago by RalfM.
Viewing 6 replies - 1 through 6 (of 6 total)
  • Hi,

    Did you try something like this?

    [pass vars]
    [if field=zip value={POSTLEITZAHL}]
    It works
    [/if]
    [/pass]

    Peter

    Thread Starter RalfM

    (@ralfm)

    Thanks Peter,
    yes, I also tried different ways of using that [pass vars] – unfortunatelly without success.

    Thread Starter RalfM

    (@ralfm)

    OK, I had some success doing this: [set postleitzahl]0[/set] PLZ: [get postleitzahl]

    [loop type=eintrag orderby=zip count=5]
    
    [loop-count]: [field zip] [field location]
    
    [pass vars]
    [if field=zip value={POSTLEITZAHL}]
    It works
    [else]
    [set postleitzahl][field zip][/set] neue PLZ: [get postleitzahl]
    [/if][/pass]
    
    [/loop]

    I get this result:
    PLZ: 0
    1: 12169 berlin (seems to be wrong sorted but lets ignore that for a while)
    neue PLZ: 12169

    2: 65197 Wiesbaden
    neue PLZ: 65197

    3: 01099 Dresden
    neue PLZ: 01099

    4: 01099 Dresden
    It works

    5: 01109 Dresden
    neue PLZ: 01109

    You see, that it has recognized the same value one time at 4: But it seems to be forgotten one later.

    • This reply was modified 7 years, 11 months ago by RalfM.
    Thread Starter RalfM

    (@ralfm)

    Sorry, I was wrong. What is shown above is correct. So IT WORKS !!

    Nice job!

    Don’t forget to mark this post as “Resolved”.

    Thread Starter RalfM

    (@ralfm)

    Thanks Peter.

Viewing 6 replies - 1 through 6 (of 6 total)

The topic ‘use variable in a [if]’ is closed to new replies.