Log in

View Full Version : If condition "OR" problem


Ghostt
07-16-2012, 05:21 PM
Hello,
I can't geht this condition to work:

<if condition="!in_array($foruminfo['forumid'], array(369,479)) OR THIS_SCRIPT != 'search'">

it should exclude conent from the forum ids 369,479 and from themplate "search".
They work separately but not together with the OR command.
can you help me`?

kh99
07-16-2012, 05:43 PM
I think you want AND instead of OR.

Ghostt
07-16-2012, 06:37 PM
wow your right .thx but in a other case OR worked for me hmm.
could you explain me why OR not work?


because my logic is :
exclude content if user visit forumdisplay.php with forum id 369,479 exclude content OR
if user visit search.php.

kh99
07-16-2012, 07:34 PM
wow your right .thx but in a other case OR worked for me hmm.
could you explain me why OR not work?


because my logic is :
exclude content if user visit forumdisplay.php with forum id 369,479 exclude content OR
if user visit search.php.


It can be tricky to convert an English description to code. But remember, you described the condition for excluding, but the if condition has to be true when you want to include the code. So you could negate the entire statement, like:

condition="!(in_array($foruminfo['forumid'], array(369,479)) OR THIS_SCRIPT == 'search'")"


which should work. Also, it's true that !(A OR B) is the same as !A AND !B, so that's why your code works with AND.