Tổng hợp Conditionals cho Newbie

Thảo luận trong 'General Discussions' bắt đầu bởi Lê Tí, 20/5/13.

1votes
5/5, 1 vote

  1. Lê Tí

    Lê Tí Well-Known Member

    Bài viết:
    1,450
    Likes :
    620
    Dành cho Newbie như mềnh đây, vừ sưu tầm được, share luôn :)) pro đừng chém nhá ;))

    XenForo Template Conditionals List

    Conditionals

    The following conditional statements will only work in templates which support the arguments and parameters.

    Statements can be expanded using AND, OR, and <xen:else />.

    Replacing == with != in the following examples 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 an argument only contains a single parameter, inserting a ! before the parameter 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.

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

    When working with the PAGE_CONTAINER template, you can pass variables from the view templates (category_view, forum_view, thread_view, etc.) using xen:container. The same applies to any templates which are included in the PAGE_CONTAINER template; the header or ad_header templates for example.
    To use the $forum.node_id variable for example, you would add this to the PAGE_CONTAINER template: <xen:container var="$forumId">{$forum.node_id}</xen:container>.
    Similarly for the $threadId variable, you would add this: <xen:container var="$threadId">{$thread.thread_id}</xen:container>.

    Where variables such as x, y, or z have been used, these must be replaced with actual values.


    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>


    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>


    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>


    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>


    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>


    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>


    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>


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


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


    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>


    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>


    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>


    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>


    How can I show content after the first post in a thread or conversation?
    <xen:if is="{$post.position} == 0">
    This content will show after the first post
    </xen:if>


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


    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>


    How can I show content after post x on every page, 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>


    How can I show content after post x on every page, 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>


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


    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.


    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>


    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>


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


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


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


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


    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>


    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>


    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>


    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>


    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>


    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>


    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>
     
    Đang tải...
  2. nttruong

    nttruong Well-Known Member

    Bài viết:
    1,518
    Likes :
    776
    bờm nhất cái thể loại copy + paste + no trans >>>> kg hiểu >>>> quăng gạch :))
    Đừng bảo search google thì tội nghiệp mấy bé nhá
     
  3. Kid

    Kid VIP Member

    Bài viết:
    863
    Likes :
    947
    Mấy cái này dễ hiểu mà gần như là cấu trúc tương tự nhau, khác có dấu = > < != ==
     
  4. nttruong

    nttruong Well-Known Member

    Bài viết:
    1,518
    Likes :
    776
    post chơi cho vui, chứ đọc kg hiểu thì cũng .... đúng kg Kid :D
     
  5. Lê Tí

    Lê Tí Well-Known Member

    Bài viết:
    1,450
    Likes :
    620
    đọc không hiểu thì cũng......biết dùng =))
     
  6. nttruong

    nttruong Well-Known Member

    Bài viết:
    1,518
    Likes :
    776
    trích dẫn đi, dùng vào đâu nè :))
     
  7. Lê Tí

    Lê Tí Well-Known Member

    Bài viết:
    1,450
    Likes :
    620
    đi làm site porn kiếm ít trafic :))
     
  8. nttruong

    nttruong Well-Known Member

    Bài viết:
    1,518
    Likes :
    776
    Chắc anh quăng theo em thì nhanh gọn :))
     
  9. ntycle

    ntycle New Member

    Bài viết:
    54
    Likes :
    9
  10. nttruong

    nttruong Well-Known Member

    Bài viết:
    1,518
    Likes :
    776
  11. Chấm

    Chấm Active Member

    Bài viết:
    649
    Likes :
    123
    Dành cho Newbie mà toàn tiếng anh k vậy anh
    Nhìn không hiểu gì hết trơn :(
     
  12. Lê Tí

    Lê Tí Well-Known Member

    Bài viết:
    1,450
    Likes :
    620
    hề hề, code và domain xong rùi, giờ post bài thâu :))
     
    nttruong thích bài này.
  13. nttruong

    nttruong Well-Known Member

    Bài viết:
    1,518
    Likes :
    776
    Nhất trí và like theo em!
     
  14. Lê Tí

    Lê Tí Well-Known Member

    Bài viết:
    1,450
    Likes :
    620
    Credit: $1,000 :))

    pm lão à lú cà hoặc tể quỉ lá rút về visa đi bác =))
     
  15. nttruong

    nttruong Well-Known Member

    Bài viết:
    1,518
    Likes :
    776
    Các bạn cứ chơi với nhau đi cho bền vững :))
     
  16. Lê Tí

    Lê Tí Well-Known Member

    Bài viết:
    1,450
    Likes :
    620
    đủ tiền mua lic xenforo rầu :))
     
  17. nttruong

    nttruong Well-Known Member

    Bài viết:
    1,518
    Likes :
    776
    theo dấu le ti! b-)
     
  18. Fox Of Dark

    Fox Of Dark Oáp.... Mấy ngày nay thức trễ

    Bài viết:
    1,102
    Likes :
    316
    đi đâu thế
    P/s: đập vô mắt cái chữ "Dành cho Newbie như mềnh đây" =))~
     
  19. nttruong

    nttruong Well-Known Member

    Bài viết:
    1,518
    Likes :
    776
    Cái chữ ký bóp nhau quá vậy em =))
     
  20. Lê Tí

    Lê Tí Well-Known Member

    Bài viết:
    1,450
    Likes :
    620
    theo làm giề? :v
     
comments powered by Disqus

Chia sẻ trang này

Đang tải...