XF 1.1 What is wrong with this template condition?

rdn

Well-known member
Code:
<xen:if is="{$postId} == 2 AND !{$visitor.user_id} AND !in_array({$forum.node_id}, array(23,26,74,76,77,79,89,93,94,95,106,108,159,160,161,162,198))">
 
CONTENT HERE
 
</xen:if>
 
 
<xen:if is="{$postId} == 3 AND !{$visitor.user_id} AND !in_array({$forum.node_id}, array(23,26,74,76,77,79,89,93,94,95,106,159,160,161,162))">
 
CONTENT HERE
 
</xen:if>



It doesn't work or display.
 
Firstly, what template are you using this in?

Next, be methodical with it...

Break it down and test it piece by piece...

So first try:

Code:
<xen:if is="{$postId} == 2">
CONTENT
</xen:if>

If that works... try the next bit...

Code:
<xen:if is="{$postId} == 2 AND !{$visitor.user_id}">
CONTENT
</xen:if>

And keep going until you identify where it has gone wrong. Most of those conditions look correct so hopefully doing it like I've suggested above will single out the one that's wrong.
 
  • Like
Reactions: rdn
Firstly, what template are you using this in?

Next, be methodical with it...

Break it down and test it piece by piece...

So first try:

Code:
<xen:if is="{$postId} == 2">
CONTENT
</xen:if>

If that works... try the next bit...

Code:
<xen:if is="{$postId} == 2 AND !{$visitor.user_id}">
CONTENT
</xen:if>

And keep going until you identify where it has gone wrong. Most of those conditions look correct so hopefully doing it like I've suggested above will single out the one that's wrong.
I tested this code:

<xen:if is="{$postId} == 2">
TEST CONTENT
</xen:if>

It didn' t work :(
 
For that template, it wouldn't work.

ad_templates are for advert code - they don't have any parameters available to them.

So basically the ad_message_below template hasn't got a clue what $postId means.
 
Yeah that should work.
Still didn't work, I inserted it inside "message" template:

Code:
<article>
                <blockquote class="messageText ugc baseHtml{xen:if $message.isIgnored, ' ignored'}">
                    <xen:include template="ad_message_body" />
 
<xen:if is="{$postId} == 2">
TEST CONTENT
</xen:if>
 
                    {xen:raw $message.messageHtml}
                </blockquote>
            </article>
 
Are you trying to show content in the post with an ID of 2 (that is, out of all of the many posts on your forum, the single post with an ID of 2) or are you trying to show content in the post in every single thread that is the 2nd post in that thread?

If the latter, I think you want this:

<xen:if is="{$message.position} == 2">
TEST CONTENT
</xen:if>

But, actually, the position starts at 0 so the second post would be 1
 
Are you trying to show content in the post with an ID of 2 (that is, out of all of the many posts on your forum, the single post with an ID of 2) or are you trying to show content in the post in every single thread that is the 2nd post in that thread?

If the latter, I think you want this:

<xen:if is="{$message.position} == 2">
TEST CONTENT
</xen:if>

But, actually, the position starts at 0 so the second post would be 1
Still not working.
 
This works for me...

<xen:if is="{$message.position} == 2">
TEST CONTENT
</xen:if>

WQilTKC.png


I don't know why it isn't working for you.
 
  • Like
Reactions: rdn
Top Bottom