Conditional Statements for XenForo 2

hacobi1102

Sen cấp 4
Mod
Bài viết
500
Thích
102
Điểm
63
Best Tư vấn
1
Xu
277
Pet
Pug mặt xệ
Chủ Top
#1
The conditional statements can be expanded by using AND, OR conditional statements operators and using xf:if, xf:else, xf:elseif.

If there are any conditional statements that you want to add, please add it as a message and the article will be updated.

1. How can I show content to Administrators?
Mã:
<xf:if is="$xf.visitor.is_admin">
    Show content...
</xf:if>
2. How can I show content to Moderators?
Mã:
<xf:if is="$xf.visitor.is_moderator">
  Show content...
</xf:if>
3. How can I show content to Administrators and Moderators?
Mã:
<xf:if is="$xf.visitor.is_admin OR $xf.visitor.is_moderator">
    Show content...
</xf:if>
4. How can I Show content for member?
Mã:
<xf:if is="$xf.visitor.user_id">
  Show content...
</xf:if>
5. How can I Show content if not a member?
Mã:
<xf:if is="!$xf.visitor.user_id">
   Show content...
</xf:if>
6. How can I show different content to members and guests?
Mã:
<xf:if is="!$xf.visitor.user_id">
  Show only members
<xf:else />
Show only guests
</xf:if>
7. How can I Show content for banned members?
Mã:
<xf:if is="$user.is_banned">
  Show content...
</xf:if>
8. How can I show content from x if the user's likes is bigger?
Mã:
<xf:if is="$user.like_count|number > x">
   Show content...
</xf:if>
9. How can I show content from x if the user's message is bigger?
Mã:
<xf:if is="$user.message_count|number > x">
   Show content...
</xf:if>
10. How can I show content from x if the user's points is bigger?
Mã:
<xf:if is="$user.trophy_points|number > x">
  Show content...
</xf:if>
11. How can I show content to a specific member?
Mã:
<xf:if is="$xf.visitor.user_id == x">
   Show content...
</xf:if>
12. How can I show content to more than one member?
Mã:
<xf:if is="in_array($xf.visitor.user_id, [x, x, x, x])">
   Show content...
</xf:if>
13. How can I Show content from more than one user group?
Mã:
<xf:if is="{{$xf.visitor.isMemberOf(x)}}">
    Show content...
</xf:if>
14. How can I hide content from more than one user group?
Mã:
<xf:if is="{{!$xf.visitor.isMemberOf(x)}}">
     Hide content...
</xf:if>
15. How can I show content after the first post in a thread?
Mã:
<xf:if is="$post.position % $xf.options.messagesPerPage == 0">
    Show content...
</xf:if>
15. How can I show content after post x on every page in a thread?
Mã:
<xf:if is="$post.position % $xf.options.messagesPerPage == x">
    Show content...
</xf:if>
16. How can I show content on pages with a sidebar?
Mã:
<xf:if is="$sidebar">
    Show content...
</xf:if>
17. How can I show content only at home?
Mã:
<xf:if is="$template != 'forum_list'">
     Show content...
</xf:if>
18. How can I hide content only at home?
Mã:
<xf:if is="$template !== 'forum_list'">
    Hide content...
</xf:if>
19. How can I show the content only when creating a thread?
Mã:
<xf:if is="$template == 'forum_post_thread'">
    Show content...
</xf:if>
20. How can I hide the content only when creating a thread?
Mã:
<xf:if is="$template != 'forum_post_thread'">
    Hide content..
</xf:if>
21. How can I show the content only when creating a resource?
Mã:
<xf:if is="$template == 'xfrm_category_add_resource'">
   Show content..
</xf:if>
22. How can I hide the content only when creating a resource?
Mã:
<xf:if is="$template != 'xfrm_category_add_resource'">
    Hide content..
</xf:if>
23. How can I show you only when viewing the search page?
Mã:
<xf:if is="$template == 'search_form'">
    Show content..
</xf:if>
24. How can I hide you only when viewing the search page?
Mã:
<xf:if is="$template != 'search_form'">
   Hide content..
</xf:if>
25. How can I show content only in what's new?
Mã:
<xf:if is="$template == 'whats_new'">
   Show content..
  </xf:if>
26. How can I hide content only in what's new?
Mã:
<xf:if is="$template != 'whats_new'">
      Hide content..
</xf:if>
27. How can I show content message on in a conversation?
Mã:
<xf:if is="$template == 'conversation_view'">
    Show content..
</xf:if>
28. How can I hide content message on in a conversation?
Mã:
<xf:if is="$template != 'conversation_view'">
    Hide content..
</xf:if>
29. How can I show only on the conversation list?
Mã:
<xf:if is="$template == 'conversation_list'">
   Show content..
</xf:if>
30. How can I hide only on the conversation list?
Mã:
<xf:if is="$template != 'conversation_list'">
    Hide content..
</xf:if>
31. How can I show only resources on the homepage?
Mã:
<xf:if is="$template == 'xfrm_overview'">
    Show content..
</xf:if>
32. How can I hide only resources on the homepage?
Mã:
<xf:if is="$template != 'xfrm_overview'">
   Hide content..
</xf:if>
33. How can I show only when viewing sources content?
Mã:
<xf:if is="$template == 'xfrm_resource_view'">
   Show content..
</xf:if>
34. How can I hide only when viewing sources content?
Mã:
<xf:if is="$template != 'xfrm_resource_view'">
   Hide content..
</xf:if>
35. How can I show when the thread is displayed?
Mã:
<xf:if is="$template == 'thread_view'">
   Show content..
</xf:if>
36. How can I hide when the thread is displayed?
Mã:
<xf:if is="$template !='thread_view'">
    Hide content..
</xf:if>
37. How can I show it in the thread list?
Mã:
<xf:if is="$template =='forum_view'">
   Show content..
</xf:if>
38. How can I hide it in the thread list?
Mã:
<xf:if is="$template != 'forum_view'">
   Hide content..
</xf:if>
39. How can I show content to Discouraged Users? [ @BegemotUral thanks ]
Mã:
<xf:if is="{$xf.visitor.Option.is_discouraged}">
     Show content...
</xf:if>
40. How can I display the content only for those users who have an Gravatar?
Mã:
<xf:if is="{$xf.visitor.gravatar}">
  Show content...
</xf:if>
41.How can I display the content only for staff?
Mã:
<xf:if is="{$xf.visitor.is_staff}">
    Show content...
</xf:if>
42.How can I display the content only for users who have not confirmed email address?
Mã:
<xf:if is="{$xf.visitor.isAwaitingEmailConfirmation()}">
  Show content...
</xf:if>
43. How can I show content in more than one forum?
Mã:
<xf:if is="in_array({$forum.node_id}, [X,Y,Z])">
                  Show content..
</xf:if>
44. How do I hide content in multiple forums?
Mã:
<xf:if is="!in_array({$forum.node_id}, [X,Y,Z])">
                  Hide content..
</xf:if>
45. How can I show content in a specific forum?
Mã:
<xf:if is="{$forum.node_id} == 3">
               Show content..
</xf:if>
46. How can I hide content on a specific forum?
Mã:
<xf:if is="{$forum.node_id} != 3">
               Hide content..
</xf:if>
47. How to show a banner only under the first post of each page of a thread?
Mã:
<xf:if is="{$post.position} % {$xf.options.messagesPerPage} == 1">
        Show content..
</xf:if>
48. How to show a banner only inside of only the first post of each page of a thread?
Mã:
<xf:if is="{$post.position} % {$xf.options.messagesPerPage} == 0">
               Show content..
</xf:if>
49. The location field is specified
Mã:
<xf:if is="{$xf.visitor.location}">
    Show content...
</xf:if>
50. The website field is specified
Mã:
<xf:if is="{$xf.visitor.website}">
    Show content...
</xf:if>
51. The signature is indicated.
Mã:
<xf:if is="{$xf.visitor.signature}">
    Show content...
</xf:if>
52. The user activated
Mã:
<xf:if is="{$xf.visitor.user_state} == 'valid'">
    Show content...
</xf:if>
53. Awaiting email confirmation (after editing):
Mã:
<xf:if is="{$xf.visitor.user_state} == 'email_confirm_edit'">
    Show content...
</xf:if>
54. Email is not valid
Mã:
<xf:if is="{$xf.visitor.user_state} == 'email_bounce'">
    Show content...
</xf:if>
I thank @BegemotUral for its contribution.
 

Du học New Zealand và mang theo thú cưng cần lưu ý gì?
  • 24
  • 0
Đưa thú cưng đi theo ra nước ngoài có dễ không, thủ tục như thế nào? Có nhiều bạn đang thắc mắc về những quy định liên quan tới vấn đề mang thú cưng theo khi đi du học New Zealand. Họ mong muốn có một người bạn đồng hành cùng đi với mình tới vùng...
Diễn đàn Thú cưng | Phụ kiện Thú cưng | Mua bán thú cưng
DMCA.com Protection Status
Top Dưới