1

I can't get working this conditional expression

<!--#if expr="$DOCUMENT_NAME!=index.html || $DOCUMENT_NAME!=links.html" -->

while this one without ! before = works perfect

<!--#if expr="$DOCUMENT_NAME=index.html || $DOCUMENT_NAME=links.html" -->

What's the problem? I get no error simply != doesn't work though || with other condition but works for single condition.

andrew
  • 426
  • 8
  • 18

1 Answers1

2

This is because = and != are hardly the same operator. Note that, by De Morgan's law (which I also explained in this old post),

a != b || c != d

is equivalent to

a = b && c = d

which is never true for x = a && x = b where a != b.

Changing the binary operator requires changing the conditionals as well to be equivalent.

Thus, by the above logic,

$DOCUMENT_NAME!=index.html || $DOCUMENT_NAME!=links.html

is equivalent to

$DOCUMENT_NAME=index.html && $DOCUMENT_NAME=links.html

which cannot be true as $DOCUMENT_NAME can be "index.html" or "links.html" but not both.

However, the 2nd snippet,

$DOCUMENT_NAME=index.html || $DOCUMENT_NAME=links.html

"works" because there is not the logical never-true fallacy mentioned above. It will be true when $DOCUMENT_NAME is either "index.html" or "links.html".


Some languages/values will violate the above equivalency .. but that is another topic.

Community
  • 1
  • 1
  • Thank you for response. However I'm still a bit confused. How then implement this idea other way? Basically I have a script in header and need to show that on all pages but not on index.html, links.html and also a few other pages I want to ignore to be show the script. – andrew Aug 29 '12 at 02:11
  • 1
    Then write what you mean: `a != b && a != c` which is equivalent to `!(a == b || a == c)`: "It is *not* the case that a is equal to b *or* c." –  Aug 29 '12 at 02:30
  • OK I understand that now. But how I can do in SSI condition to exclude showing script on particular pages? – andrew Aug 29 '12 at 02:38
  • 1
    `$DOCUMENT_NAME!=index.html && $DOCUMENT_NAME!=links.html` or `!($DOCUMENT_NAME=index.html || $DOCUMENT_NAME=links.html)` should do the trick. –  Aug 29 '12 at 02:47
  • Thank you! `!($DOCUMENT_NAME=index.html || $DOCUMENT_NAME=links.html)` That's what I was looking for. – andrew Aug 29 '12 at 02:57