• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

XF 1.4 Inline conditional

RichardKYA

Well-known member
#1
Hello all,

I'm trying to get this to work...

Code:
{xen:if '{$contentTemplate} != "forum_list" || {$contentTemplate} != "pagenode_container"', 'filter'}
...what am I doing wrong?

Thank you kindly :)
 

Chris D

XenForo developer
Staff member
#2
What specifically is/isn't happening when using it?

At first glance it looks ok to me from a syntax point of view.
 

RichardKYA

Well-known member
#3
Basically, it's just ignoring these conditions and applying the class anyway. The conditions work fine if I separate them and do them individually, but using the || doesn't seem to work :confused:
 

Chris D

XenForo developer
Staff member
#4
Actually, the syntax does appear to be correct. I didn't really focus on the logic behind the statement.

|| is the same as saying OR

!= is the same as saying NOT EQUAL

In that case, the logic says if the template is anything at all, apply the class, e.g:

If the template IS forum_list then it is NOT EQUAL to pagenode_container therefore it will add the filter class.
If the template is (as an example) thread_view then it is not equal to pagenode_container and it is not equal to forum_list therefore it will add the filter class.

What exactly are you trying to do, I think you need to use slightly different logic to achieve it.
 

RichardKYA

Well-known member
#5
Of course, that makes perfect sense now that I think about it.

I want the class to be added to all templates apart from the forum_list and page_container.

How about something like...

Code:
{xen:if '{$contentTemplate} == "forum_list" || {$contentTemplate} == "pagenode_container"', '', 'filter'}
 

RichardKYA

Well-known member
#6
Hold on, wouldn't && solve my problems...

Code:
{xen:if '{$contentTemplate} != "forum_list" && {$contentTemplate} != "pagenode_container"', 'filter'}
Lmao, stupid brain
 

RichardKYA

Well-known member
#9
Awesome, I think I will use that way, as I also want to add help_index to the mix, plus I can easily add more if I need to.

Thank you Chris, this is very helpful (y)