XF 2.0 Check entity property exists in template

MetalAZ

Member
I'm doing some stuff with the news_feed_macros template but only want to do something if the entity has "message", which not all do. Is there a way in the template that I can check that "message" exists on the entity? I've tried
Code:
is="$item.Content.message"
but get the "Accessed unknown getter 'message' on" error showing up, for the entities that don't have that.
 
There's not really a way to detect whether a field exists, but you could check a list of content types instead:
Code:
is="in_array($item.content_type, ['post', 'profile_post', 'profile_post_comment'])"
 
Top Bottom