Announcement

Collapse
No announcement yet.

Problem with Block If Statements

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Problem with Block If Statements

    I am trying to use a Block if statement to control whether something displays or not. The following statement works perfectly:

    <actinic:block if="%3cactinic%3avariable%20name%3d%22SectionName%22%20%2f%3e%20%20%21%3d%20%22Log%20Splitters%20and%20Saw%20Horses%22" >
    <actinic:variable name="SectionFragmentList" />
    </actinic:block>

    The code in the block translates to:

    <actinic:variable name="SectionName" /> != "Log Splitters and Saw Horses"

    The following statement also works perfectly:

    <actinic:block if="%3cactinic%3avariable%20name%3d%22SectionName%22%20%2f%3e%20%20%21%3d%20%22Hedgetrimmers%22" >
    <actinic:variable name="SectionFragmentList" />
    </actinic:block>

    The code in the block translates to:

    <actinic:variable name="SectionName" /> != "Hedgetrimmers"

    The effect of this code, in the first instance, is that everything is displayed unless the Section Name is Log Splitters and Saw Horses and in the 2nd instance, everything is displayed unless the Section Name is Hedgetrimmers.

    What I want to do is "OR" the 2 statements together so that everything is displayed unless the Section Name is "Log Splitters and Saw Horses" OR it is "Hedgetrimmers".

    I have tried every permutation I can think of, but without success. As soon as I try to OR them together, everything is is let through including Log Splitters and Saw Horses and Hedgetrimmers.

    What am I doing wrong please? Help!

    #2
    Have you tried this:
    <actinic:variable name="SectionName" /> != "Hedgetrimmers" AND <actinic:variable name="SectionName" /> != "Log Splitters and Saw Horses"
    Untested - and it's th eend of the day!

    Otherwise you could maybe place a BlockIf around the BlockIf around the code - if you know what mean.

    Comment


      #3
      Thank you so much - that works a treat. I was obviously bogged down thinking it would be an OR combination (which made more sense to me) but clearly I got that wrong.

      Your solution, combined with another bit of code, has enabled me to place fragments either before pagination results or after them - which is what I wanted to do.

      Thank you again for your help.

      Comment


        #4
        For anyone reading this who doesn't understand the precedence of logical operators, you can use brackets around expressions to make them clearer.
        E.g.
        Code:
        (<actinic:variable name="SectionName" /> != "Hedgetrimmers") AND (<actinic:variable name="SectionName" /> != "Log Splitters and Saw Horses")
        And with maths using brackets makes things a lot clearer. E.g.
        1 + 2 * 3 equates to 7 (because * is evaluated before +).
        But
        1 + (2 * 3) does the same thing but you don't need to know about precedence to see how it works.
        Norman - www.drillpine.biz
        Edinburgh, U K / Bitez, Turkey

        Comment


          #5
          Thank you for the update and additional info Norman. Your previous code on fragments is working a treat for me - first class!

          Comment

          Working...
          X