XF 1.2 Conditional Statement issue

Moddis

Active member
I am using the beautiful resource on conditional Statements but ran into an issue with combining one of them:

How can I show content after post x on every page in a thread or conversation?
<xen:if is="{$post.position} % {$xenOptions.messagesPerPage} == x">
This content will show after post x on every page
</xen:if>

<xen:if is="{$post.position} % {$xenOptions.messagesPerPage} == 20 OR {$post.position} == 0">
TEXT
</xen:if>

Ideally that should show me the TEXT in the first post of every page of a thread. 20 is the correct number of post that i have set up per thread page so it should work. is there another variable I am missing?

Thanks!
 
Last edited:
What is the current functionality of what you are using? And if you want it to show after the first post, you should be doing == 0.


The second part of the statement does have the 0 criteria so it shows up correctly in the first post of the thread. However, if does not show up as the first post (actually the 21st) of the same thread on page 2.

BTW, I entered the incorrect quote so I updated the original thread with instruction on how it says to "How can I show content after post x on every page in a thread or conversation?"

Thanks!

 
You will need to duplicate it for $message.message_id. Try this:
Code:
<xen:if is="{$post.position} % {$xenOptions.messagesPerPage} == 1 OR {$message.message_id} % {$xenOptions.messagesPerPage} == 1">
Text
</xen:if>
 
Oops, I also just realized I could have just used the "<xen:if is="{$post.position} % {$xenOptions.messagesPerPage} == 0">" without combining it without OR statement and it worked as well. The thing I was doing wrong is putting a 20 instead of a 0 like in your example.

Thanks for the quick help!
 
This is a little bit different of an issue but is an additional that I would like to add to the conditional statement.

Is there something that would Not show to "TEXT" if the post author is part of user group x?
 
Yes. Paul's resource explains how to use ismemberof.

How can I hide content from a specific user group?
<xen:if is="!{xen:helper ismemberof, $visitor, x}">
This content will be hidden from members of user group x
</xen:if>
 
I looked at that one but im trying to figure out if i can tweak it to, not hide content FROM a specific user group but hide content if the actual post is made by a specific user group.

Paul's instructions say that $visitor is always the record for the current logged in user and $user is the record being processed(e.g message author). So using that, I guess i will try to transform your suggestion from $visitor to $user and see if its as simple as that to make it work:

<xen:if is="!{xen:helper ismemberof, $user, x}">
TEXT
</xen:if>
 
<xen:if is="!{xen:helper ismemberof, $user, x}">
TEXT
</xen:if>
(I replaced x with the user group id number)

The above is not working and its giving me a bunch of errors on top of page:

Code:
Template Errors: thread_view
Argument 1 passed to XenForo_Template_Helper_Core::helperIsMemberOf() must be of the type array, null given in

Argument 1 passed to XenForo_Model_User::isMemberOfUserGroup() must be of the type array, null given, called in

Argument 1 passed to XenForo_Template_Helper_Core::helperIsMemberOf() must be of the type array, null given in

Argument 1 passed to XenForo_Model_User::isMemberOfUserGroup() must be of the type array, null given, called in

.....

This is not super important because I dont plan on using it this way for a long time but if there is anything else you think can be tried, please do let me know.
 
$user doesn't exist in this context. What template were you using this conditional in?
I'm using it in the "ad_message_body" template.

Again, to be clear, I would like to display "This Text" to all users and in every posts except if that post was made by usergroup 11.
 
Back with another question about this conditional:

How can I show content after post x on every page in a thread or conversation?
<xen:if is="{$post.position} % {$xenOptions.messagesPerPage} == x">
This content will show after post x on every page
</xen:if>

It is added to the "ad_message_below" template and it works great for showing the content under the first post of every thread/page. However, its is showing the same content under every single conversation message if I set the x to 0. If i set x to 1, it does not show the content at all.
 
I would like to also show in conversation view but also just in the first message and not all of them.

I know I can use this to restrict it completely to the first post but is there something specific that would help me identify the first message of a conversation (maybe <<xen:if is="{$message.conversation_id} == 0 "> ?)
How can I show content after the first post in a thread?
<xen:if is="{$post.position} == 0 AND !{$message.conversation_id}">
This content will show after the first post in a thread
</xen:if>
 
This one should function:
Unfortunately that does not work. It just meets the first criteria and still shows it in every conversation message. Also tried to test by deleting the first part (before the Or) but the second part did not have any affect and did not show content anywhere in conversation.
 
Back
Top Bottom