Status
Not open for further replies.
S

strykerhd

trying to add a block in my header template that shows certain content to a specific secondary usergroup. But i can't for the life of me figure out the xen code to make sure visitor is of that group, can someone give me an example of the code needed to show this?
 
The following conditional statements will only work if the variables are supported in the respective templates.
To determine whether a variable is available in a template, see this guide: Using variables in templates
Statements can be expanded using AND, OR, xen:else and xen:elseif.
Replacing == with != when referencing a numerical value will change the condition from true to false, for example:
<xen:if is="{$visitor.user_id} == x"> for true
<xen:if is="{$visitor.user_id} != x"> for false
Where a statement only contains a single variable, inserting a ! before it has the same effect, for example:
<xen:if is="{$visitor.user_id}"> for true
<xen:if is="!{$visitor.user_id}"> for false
When working with arrays, the ! is placed just before the argument, for example:
<xen:if is="in_array({$forum.node_id}, array(x, y, z))"> for true
<xen:if is="!in_array({$forum.node_id}, array(x, y, z))"> for false
Using xen:else and xen:elseif, multiple conditions can be incorporated into a single statement.
The simplest form would utilise xen:else like so:
<xen:if is="{$forum.node_id} == x">
This content will show in forum x
<xen:else />
This content will show everywhere else
</xen:if>
A more advanced statement, with multiple conditions using xen:elseif would be as follows:
<xen:if is="{$forum.node_id} == x">
This content will show in forum x
<xen:elseif is="{$forum.node_id} == y" />
This content will show in forum y
<xen:elseif is="{$forum.node_id} == z" />
This content will show in forum z
<xen:else />
This content will show everywhere else
</xen:if>
Depending on the template being worked with, you may need to use $user instead of $visitor; $visitor is always the record for the current logged in user, $user is the record being processed (e.g. message author, member list, list of online users, etc.).
Where variables such as x, y, or z have been used, these must be replaced with actual values.

1. How can I show content just to logged in members and hide it from guests?
<xen:if is="{$visitor.user_id}">
This content will show to logged in members
</xen:if>

2. How can I show content just to guests and hide it from logged in members?
<xen:if is="!{$visitor.user_id}">
This content will show to guests
</xen:if>

3. How can I show different content to guests and logged in members?
<xen:if is="{$visitor.user_id}">
This content will show to logged in members
<xen:else />
This content will show to guests
</xen:if>

4. How can I show content to a specific user group?
<xen:if is="{xen:helper ismemberof, $visitor, x}">
This content will show to members of user group x
</xen:if>

5. 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>

6. How can I show content to more than one user group?
<xen:if is="{xen:helper ismemberof, $visitor, x, y}">
This content will show to members of user groups x or y
</xen:if>

7. How can I hide content from more than one user group?
<xen:if is="!{xen:helper ismemberof, $visitor, x, y}">
This content will be hidden from members of user groups x or y
</xen:if>

8. How can I show content to Administrators?
<xen:if is="{$visitor.is_admin}">
This content will show to Administrators
</xen:if>

9. How can I show content to Moderators?
<xen:if is="{$visitor.is_moderator}">
This content will show to Moderators
</xen:if>

10. How can I show content to Administrators and Moderators?
<xen:if is="{$visitor.is_admin} OR {$visitor.is_moderator}">
This content will show to Administrators and Moderators
</xen:if>

11. How can I show content to staff members?
<xen:if is="{$visitor.is_staff}">
This content will show to staff members
</xen:if>
Note that this is dependent on the Display user as staff option being enabled in the ACP.

12. How can I show content to a specific member?
<xen:if is="{$visitor.user_id} == x">
This content will show to member x
</xen:if>

13. How can I show content to more than one member?
<xen:if is="in_array({$visitor.user_id}, array(x, y, z))">
This content will show to members x, y and z
</xen:if>

14. How can I show content if the visitor is the user?
<xen:if is="{$visitor.user_id} == {$user.user_id}">
This content will show if the visitor is the user
</xen:if>

15. How can I show content if the user is banned?
<xen:if is="{$user.is_banned}">
This content will show if the user is banned
</xen:if>

16. 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 on the first page only
</xen:if>

17. How can I show content after the first post on every page in a thread?
<xen:if is="{$post.position} % {$xenOptions.messagesPerPage} == 0 AND !{$message.conversation_id}">
This content will show after the first post on every page
</xen:if>

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

19. How can I show content after post x on every page in a thread, only in forums y and z?
<xen:if is="{$post.position} % {$xenOptions.messagesPerPage} == x AND in_array({$thread.node_id}, array(y, z))">
This content will show after post x on every page, only in forums y and z
</xen:if>

20. How can I show content after post x on every page in a thread, except in forums y and z?
<xen:if is="{$post.position} % {$xenOptions.messagesPerPage} == x AND !in_array({$thread.node_id}, array(y, z))">
This content will show after post x on every page, except in forums y and z
</xen:if>

21. How can I show content after the first message in a conversation?
<xen:if is="{$conversation} AND {$message.position_on_page} == 1 AND {$page} == 0">
This content will show after the first message on the first page only
</xen:if>

22. How can I show content after the first message on every page in a conversation?
<xen:if is="{$conversation} AND {$message.position_on_page} == 1">
This content will show after the first message on every page
</xen:if>

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

24. How can I show content on a specific page?
<xen:if is="{$contentTemplate} == 'xyz'">
This content will show on the xyz template
</xen:if>

25. How can I show content on pages with a sidebar?
<xen:if is="{$sidebar}">
This content will show on pages with a sidebar
</xen:if>

26. How can I show content in a specific category?
<xen:if is="{$category.node_id} == x">
This content will show in category x
</xen:if>
Note that in order for this to work, you must have categories set as pages in the ACP -> Options -> Node & Forum List: Create Pages for Categories.
Additionally, to ensure the category ID is available in the ad_* templates, the category_view template must be edited and the following code added: <xen:container var="$category.node_id">{$category.node_id}</xen:container>

27. How can I show content in a specific forum?
<xen:if is="{$forum.node_id} == x">
This content will show in forum x
</xen:if>

28. How can I show content in more than one forum?
<xen:if is="in_array({$forum.node_id}, array(x, y, z))">
This content will show in forums x, y, and z
</xen:if>

29. How can I show content in all forums with a specific parent?
<xen:if is="{$forum.parent_node_id} == x">
This content will show in forums of parent x
</xen:if>

30. How can I show content in a specific thread?
<xen:if is="{$thread.thread_id} == x">
This content will show in thread x
</xen:if>

31. How can I show content in more than one thread?
<xen:if is="in_array({$thread.thread_id}, array(x, y, z))">
This content will show in threads x, y, and z
</xen:if>

32. How can I show content in a specific post?
<xen:if is="{$post.post_id} == x">
This content will show in post x
</xen:if>

33. How can I show content in more than one post?
<xen:if is="in_array({$post.post_id}, array(x, y, z))">
This content will show in posts x, y, and z
</xen:if>

34. How can I show content to the thread author?
<xen:if is="{$thread.user_id} == x">
This content will show to thread author x
</xen:if>

35. How can I show content if the post author is the thread author?
<xen:if is="{$post.user_id} == {$thread.user_id}">
This content will show if the post author is the thread author
</xen:if>

36. How can I show content to members with 0 posts?
<xen:if is="{$visitor.message_count} == 0">
This content will show to members with 0 posts
</xen:if>

37. How can I show content to members with more than x posts?
<xen:if is="{$visitor.message_count} > x">
This content will show to members with more than x posts
</xen:if>

38. How can I show content to members with less than x posts?
<xen:if is="{$visitor.message_count} < x">
This content will show to members with less than x posts
</xen:if>

39. How can I show content to members who are visible?
<xen:if is="{$user.visible}">
This content will show to members who are visible
</xen:if>

40. How can I show content to members who have an avatar?
<xen:if is="{$visitor.avatar_date} OR {$visitor.gravatar}">
This content will show to members who have an avatar
</xen:if>

41. How can I show content to members who do not have an avatar?
<xen:if is="!{$visitor.avatar_date} AND !{$visitor.gravatar}">
This content will show to members who do not have an avatar
</xen:if>

42. How can I show content to members who have completed a custom user field?
<xen:if is="{$visitor.customFields.field_id}">
This content will show to members who have completed the custom user field
</xen:if>
Note that field_id must be replaced with the actual custom user field identifier.

43. How can I show content to members who have not confirmed their email address?
<xen:if is="{$isAwaitingEmailConfirmation}">
This content will show to members who have not confirmed their email address
</xen:if>

44. How can I show content to visitors arriving from search engines?
<xen:if is="{$visitor.from_search}">
This content will show to visitors arriving from search engines
</xen:if>
 
Due to that the problem has been solved, this thread was locked!

Thank you for your help @boo !

If you think, this thread should be re-opened, please write me a PM immediatly!
If you have any other questions, feel free to open a new thread in the help forums!
 
so i m using
Code:
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>

but running into an issue since most of my members are part of multiple groups. i can't get this to block for all members of the specific group even if they are part of anther group.
 
Status
Not open for further replies.

741Threads
2,309Messages
67,558Members
sunwinmolettyyLatest member
Back