XF 2.2 User _relations as a conditional statement?

In what manner? They are both accessible on the object for you to use how you wish.

PHP:
if ($entity->Category) {
    // ...
}
 
It's the same object and can be accomplished equivalently:

HTML:
<xf:if is="$entity.Category">
    <!-- ... -->
</xf:if>
 
Weird, because I tried the full path and it doesn't work. It works for _value variables though.

<xf:if is="$xf.reply.viewParams.resource.Category.custom == '134'">
 
No idea why that would be but it would typically point to a more fundamental problem. The view parameters aren't typically accessible via $xf.reply.viewParams. Otherwise you might try dumping the objects to ensure they're what you'd expect them to be:

HTML:
{{ dump($resource) }}
{{ dump($resource.Category) }}
 
Yea it seems like dumping the object itself has the variables but doesn't return the values I need like it does if I just do a full dump vars. Hence explains why it's not working.
{{ dump($xf.reply.viewParams.resource) }}

Oh well xP
 
No idea why that would be but it would typically point to a more fundamental problem. The view parameters aren't typically accessible via $xf.reply.viewParams. Otherwise you might try dumping the objects to ensure they're what you'd expect them to be:

HTML:
{{ dump($resource) }}
{{ dump($resource.Category) }}
Wait it works when I use this
{{ dump($xf.reply.viewParams.resource.Category) }}
And shows this
1709881461922.webp

So I tried this <xf:if is="$xf.reply.viewParams.resource.Category.slug == 'og'">
Doesn't work :/
 
That dump shows some object (unclear if it's an entity at all) that has a protected property called room which is an array with a slug key. None of that is in the core so I can't tell you if or how the protected property could be accessed.

You might also try {{ dump(vars()) }} to see if there's another variable with the object you're looking for, as again using $xf.reply is not typical.
 
Back
Top Bottom