Tổng hợp xenforo code Conditionals phần 2

Thảo luận trong 'Mã nguồn Xenforo' bắt đầu bởi phamcongson, 21/11/15.

  1. phamcongson

    phamcongson

    Police

    Tham gia ngày:
    3/6/13
    Bài viết:
    481
    Đã được thích:
    97
    Điểm thành tích:
    28
    Giới tính:
    Nam
    Here is a list of template conditionals that are useful to show or hide things based on certain criteria.

    1.Show To Members Only
    • If you want to show certain content to members only then this conditional is for you.
    Mã:
    <xen:if is="{$visitor.user_id}">
    Content
    </xen:if> 
    2.Show To Guests Only
    • If you want to show certain content to guests only then this conditional is for you.
    Mã:
    <xen:if is="!{$visitor.user_id}">
    Content
    </xen:if>
    3.Show Content To A Specific User Group
    • If you want to show content to a specific usergroup then this conditional is for you.
    Mã:
    <xen:if is="{xen:helper ismemberof, $visitor, x}">
    Content
    </xen:if>
    4.Hide Content From A Specific User Group
    • If you want to hide content from a specific usergroup then this conditional is for you.
    Mã:
    <xen:if is="!{xen:helper ismemberof, $visitor, x}">
    Content
    </xen:if>
    5.Show Content To Multiple User Groups
    • If you want to show content to multiple user groups using one conditional then this conditional is for you. Replace 1, 2, 3 with the user groups you want to see Content. Do not place a comma after your last user group id.
    Mã:
    <xen:if is="{xen:helper ismemberof, $visitor, 1, 2, 3}">
    Content
    </xen:if> 
    6.Hide Content From Multiple User Groups
    • If you want to hide content from multiple user groups using one conditional then this conditional is for you. Replace 1, 2, 3 with the user groups you want to hide Content from. Do not place a comma after your last user group id.
    Mã:
    <xen:if is="!{xen:helper ismemberof, $visitor, 1, 2, 3}">
    Content
    </xen:if> 
    7.Show Content To Admins Only
    • If you want to show content to Admins only you can use this conditional.
    Mã:
    <xen:if is="{$visitor.is_admin}">
    Content
    </xen:if> 
    8.Show Content To Moderators Only
    • If you want to show content to Moderators only you can use this conditional.
    Mã:
    <xen:if is="{$visitor.is_moderator}">
    Content
    </xen:if> 
    9.Show Content To Both Admins and Moderators
    • If you have content that you want both your Admins and Moderators to see but no one else then this conditional is for you. This also shows an example using the OR operator.
    Mã:
    <xen:if is="{$visitor.is_admin} OR {$visitor.is_moderator}">
    Content
    </xen:if> 
    10.Show Content Only On Certain Templates
    • If you have content that you want to display only on certain parts of the forum you can use this conditional in combination with the template for that page. The most popular templates are forum_list (forum home page), forum_view (individual forum page) and thread_view (individual thread pages)
    • Nếu là trang chủ thì thực hiện lệnh gì đó, ngược lại là trong con hoặc trang bài viết thực hiện các lệnh nào đó như dưới.
    Mã:
    <xen:if is="{$contentTemplate} == 'xyz'">
    Content
    </xen:if> 
     
    Cảm ơn đã xem bài:

    Tổng hợp xenforo code Conditionals phần 2

    Last edited by a moderator: 23/7/16
    Đang tải...


: xenforo code

Like và Share ủng hộ ITSEOVN