Log in

View Full Version : Conditionals problem combining with "==" works but "!=" doesn't


L2V
07-10-2008, 12:46 AM
I am working on some template modifications and have come across a problem on my 3.7.2 test board. I am trying to get something to show up in all areas of the forum except for a showthread page, blog page or social groups page.

Check out these following code samples and please tell me if I am doing something wrong...

<if condition="THIS_SCRIPT != 'showthread'">not showthread<br /></if>
<if condition="THIS_SCRIPT != 'blog'">not blog<br /></if>
<if condition="THIS_SCRIPT != 'group'">not group<br /></if>
Behaves correctly and as expected

<if condition="THIS_SCRIPT == 'index' OR THIS_SCRIPT == 'forumdisplay' OR THIS_SCRIPT == 'usercp' OR THIS_SCRIPT == 'private' OR THIS_SCRIPT == 'memberlist' OR THIS_SCRIPT == 'search' OR THIS_SCRIPT == 'faq'">if is script test<br /></if>
Behaves as expected. If the page is any of these scripts it

<if condition="THIS_SCRIPT != 'showthread' OR THIS_SCRIPT != 'blog' OR THIS_SCRIPT != 'group'">not conditionals combined<br /></if>
Doesn't work at all. The test text show up on every page.

Why? Is it supposed to behave this way? What am I doing wrong?:confused:

skhms
07-10-2008, 01:06 AM
That last example will of course always return true.

THIS_SCRIPT will always be not equal to either showthread, blog or group.

Try using AND instead of OR.

/SK

Dismounted
07-10-2008, 05:30 AM
Nice and compact is always good :).
<if condition="in_array(THIS_SCRIPT, array('index', 'forumdisplay', 'usercp', 'private', 'memberlist', 'search', 'faq'))">if is script test<br /></if>
<if condition="!in_array(THIS_SCRIPT, array('showthread', 'blog', 'group'))">not conditionals combined<br /></if>

L2V
07-10-2008, 10:13 AM
Brilliant! Thanks so much to both of you!