XF 2.0 Conditional in post_macros

Steve F

Well-known member
Not having much luck....neither of these work.

HTML:
{{ $post.is_staff ? 'is-staff': ''}}

HTML:
{{ $post.User.is_staff ? 'is-staff': ''}}

Any ideas, I think I'm just missing how this works.
 
So what would be the correct syntax for the below:

HTML:
{{ property('peThreadStarter') && $post.user_id == $thread.user_id ? 'is-threadStarter' : '' }}

property('peThreadStarter') is set as a boolean.

The output of that is showing a "1" instead of "is-threadStarter":
1504755370892.webp

This works alone:
HTML:
{{ property('peThreadStarter') ? 'is-threadStarter' : '' }}
1504755506499.webp

What am I missing?
 
Well I would delete the above just because it is a bit embarrassing but that wouldn't help anyone :p

Working (added bit in red, thanks @Russ :)):
Rich (BB code):
{{ ($post.user_id == $thread.user_id && property('peThreadStarter')) ? ' is-threadStarter' : '' }}
 
Well I would delete the above just because it is a bit embarrassing but that wouldn't help anyone :p

Working (added bit in red, thanks @Russ :)):
Rich (BB code):
{{ ($post.user_id == $thread.user_id && property('peThreadStarter')) ? ' is-threadStarter' : '' }}
Could this be used for Thread Starter (Original Poster) type modification?
 
Could this be used for Thread Starter (Original Poster) type modification?
Are you using this in a html template in a "if" statement?
Just curious because I was using the method below until XF2 beta 3 dont agree with it.
And now I am trying to find another way.
See Here...
 
Top Bottom