AcidCat
Member
javascript it is then.As far as I know, that's not possible only with template conditionals.
javascript it is then.As far as I know, that's not possible only with template conditionals.
6. How can I show different content to members and guests?
Code:
<xf:if is="!$xf.visitor.user_id">
Show only members
<xf:else />
Show only guests
</xf:if>
6. How can I show different content to members and guests?
Code:
<xf:if is="$xf.visitor.user_id">
Show only members
<xf:else />
Show only guests
</xf:if>
<xf:if is="$xf.visitor.is_admin OR $xf.visitor.is_moderator">
Show content...
</xf:if>
To the best of my knowledge this should work; i don't see a reason why it wouldn't..How to check if user watching thread is admin or moderator? I tried with this code:
This is error I get:To the best of my knowledge this should work; i don't see a reason why it wouldn't..
And I used it like this for example I mentioned:Line 28: Found a contentcheck tag without a contentcheck-based if tag. - Template modifications: public:message_macros
$0
<xf:if is="$xf.visitor.is_admin OR $xf.visitor.is_moderator">
<dl class="pairs pairs--justified">
<dt>{{ phrase('last_seen') }}</dt>
<dd dir="auto">
<xf:contentcheck><xf:useractivity user="$user" class="pairs--plainLabel" /></xf:contentcheck>
</dd>
</dl>
</xf:if>
$0
<xf:if is="$xf.visitor.is_admin OR $xf.visitor.is_moderator">
<xf:if contentcheck="true">
<dl class="pairs pairs--justified">
<dt>{{ phrase('last_seen') }}</dt>
<dd dir="auto">
<xf:contentcheck><xf:useractivity user="$user" class="pairs--plainLabel" /></xf:contentcheck>
</dd>
</dl>
</xf:if>
</xf:if>
Thanks, this solved this problem.The error message says all
Did you try<xf:if is="{$xf.visitor.Profile.custom_fields.PhoneName} == 'Jack\'s iPhone'">
?
It's really random... no certainty on that.
I just tried that, unfortunately it didn't work, I originally tried putting a back slash before and after it.
<xf:if is="{$xf.visitor.Profile.custom_fields.PhoneName} == 'Jack'\''s iPhone'">
How about...
PHP:<xf:if is="{$xf.visitor.Profile.custom_fields.PhoneName} == 'Jack'\''s iPhone'">
Try this:
HTML:<xf:set var="$var" value="Jack's iPhone" /> <xf:if is="{$xf.visitor.Profile.custom_fields.PhoneName} == $var">
untested, but may work.
if (!(FALSE OR TRUE OR TRUE)) {
echo "5)\n";
}
if (!(FALSE AND TRUE AND TRUE)) {
echo "6)\n";
}
Result:
6)
<xf:if is="(!(FALSE OR TRUE OR TRUE))">
FTT.
</xf:if>
<xf:if is="(!(FALSE AND TRUE AND TRUE))">
FTT and.
</xf:if>
Result:
FTT.
FTT and.
<xf:if is="(array_intersect([3,4], [3,4,5,6]))">
Result
</xf:if>
is
attribute supports logical operators:OR
/ ||
- used to link alternative conditionsAND
/ &&
- used to link additional conditions!
- place before a condition to invert itXOR
- returns true if only one of two conditions is truesrc/XF/Template/Templater.php
to see what filters and functions are available - array_intersect
is not.Thanks for your feedback, and how do I get the examples above to work with inverting?! - place before a condition to invert it
Interesting question!Why is it not working in XenForo?
if (!(false OR true) OR true) {
$__finalCompiled .= '
FTT.
';
Yeah, but this seems to be a bug in XF core, because the template code is translated to something different.Template code is not a substitute for PHP.
How did you get the compiled code?Interesting question!
I gave your code a test run and it was compiled to:
PHP:if (!(false OR true) OR true) { $__finalCompiled .= ' FTT. ';
Yeah, but this seems to be a bug in XF core, because the template code is translated to something different.
Bug-report:
Fixed - Templates: "if" conditions in some cases not translated correctly into PHP
If you have this if condition in a template: FTT. then the compiled PHP code looks like this: if (!(false OR true) OR true) { $__finalCompiled .= ' FTT. '; It would be expected that nothing was printed, but because of falsely set brackets (!(false OR true), the outcome is...xenforo.com
I searched for the stringHow did you get the compiled code?
FTT.
. You can find the compiled templates in internal_data/code_cache/templates
.We use essential cookies to make this site work, and optional cookies to enhance your experience.