Support » Plugin: Custom Content Shortcode » Comparing two variables not working

  • Resolved designforhumansstudio

    (@designforhumansstudio)


    Hello,
    I already used this Plug In quite a lot and it works very well. But I cannot find a solution for this problem:

    I just want to check, if in my posts (courses) the field year_for_sorting has always the same content, or not. If it has at least two different values, I want to add a headline in a following function. Everything seems to work fine, except the if-condition:

    [set last]0[/set]
    [set mtocount]0[/set]
    
    [loop type=courses orderby=year_for_sorting]
    
    [set new][field year_for_sorting][/set]
    
    [pass vars]
    
    [if var=new not value='{LAST}']
    [set mtocount][calc]mtocount+1[/calc][/set]
    [/if]
    
    [set last][field year_for_sorting][/set]
    
    [/loop]

    The variable mtcount will be used later, to show the headlines, if its value is higher than 1.

    Do you see any mistake?

    Jens

    The page I need help with: [log in to see the link]

Viewing 4 replies - 1 through 4 (of 4 total)
  • Try:

    [if var=new not value='{LAST}’ or not var_2=new]
    [calc]mtocount = mtocount+1[/calc]
    [/if]

    • This reply was modified 2 months, 1 week ago by polarracing.
    Thread Starter designforhumansstudio

    (@designforhumansstudio)

    Thank you for the quick reply. I tried your idea, but does not change the results. It always considers both variables different, also in the last test, when they both contain “2020”. You can see that on the website, where I show the content of the three variables… Any other idea?

    • This reply was modified 2 months, 1 week ago by designforhumansstudio. Reason: I didn't see the first solution in my email

    Then try

    [loop type=courses orderby=year_for_sorting]
    
    [pass vars]
    [if field=year_for_sorting not value='{LAST}']
    [set mtocount][calc]mtocount+1[/calc][/set]
    [/if]
    
    [set last][field year_for_sorting][/set]
    
    [/loop]
    • This reply was modified 2 months, 1 week ago by polarracing.
    Thread Starter designforhumansstudio

    (@designforhumansstudio)

    Thanks a lot for your idea. But there was still a little detail missing, what I found out only now (two days later). The closing tag of [pass vars] was missing. But now it works perfectly:

    [loop type=courses orderby=year_for_sorting]
    
    [pass vars]
    [if field=year_for_sorting not value='{LAST}']
    [set mtocount][calc]mtocount+1[/calc][/set]
    [/if]
    [/pass]
    
    [set last][field year_for_sorting][/set]
    
    [/loop]
Viewing 4 replies - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.