Addon 2x Template Parent - Thêm biến templateParent cho XenForo 2

PVS

Super Moderator
Thành viên BQT
Tham gia
28/02/2015
Bài viết
16,829
Được Like
12,687
Template Parent - Thêm biến templateParent cho XenForo 2 1.0.0

Thêm một biến template mới $xf.reply.templateParent để nhóm tất cả các template thread_view*forum_view* lại với nhau.

XenForo 2.2 thêm nhiều biến thể cho các template thread_viewforum_view cho các loại chủ đề mới khác nhau:
  • thread_view_type_article
  • thread_view_type_poll
  • thread_view_type_question
  • thread_view_type_suggestion
  • forum_view_type_article
  • forum_view_type_question
  • forum_view_type_suggestion
Vì vậy, bây giờ khi bạn muốn nhắm mục tiêu một template có điều kiện đến trang thread view (ví dụ: trong một quảng cáo), thay vì trước đây làm như sau:
HTML:
<xf:if is="$xf.reply.template == 'thread_view'">
    <!-- do something -->
</xf:if>

... bây giờ chúng ta phải làm như sau:
HTML:
<xf:if is="in_array($xf.reply.template, [
                'thread_view',
                'thread_view_type_article',
                'thread_view_type_poll',
                'thread_view_type_question',
                'thread_view_type_suggestion'
               ])">
    <!-- do something -->
</xf:if>

Một cách dễ dàng hơn

Add-on này thêm một biến template mới mà chúng ta có thể sử dụng để kiểm tra xem template "parent" là thread_view hay forum_view, vì vậy chúng ta có thể chỉ cần làm như sau để nhắm mục tiêu tất cả các template thuộc loại đó:
HTML:
<xf:if is="$xf.reply.templateParent == 'thread_view'">
    <!-- do something for any thread view pages -->
</xf:if>

... hoặc:
Mã:
<xf:if is="$xf.reply.templateParent == 'forum_view'">
    <!-- do something for any forum view pages -->
</xf:if>

Chúc các bạn thành công.


Nguồn: xenforo.com​
 

Đính kèm

  • Hampel-TemplateParent-1.0.0.zip
    11.6 KB · Lượt xem: 13

Hướng dẫn sử dụng

XenForo 1 XenForo 2
Translate by PVS

Dịch vụ XenForo của VNXF

Mobile/Zalo: 0906081284

Telegram: anhanhxf

Chỉ nhận web nội dung lành mạnh

Nhà Tài Trợ

Mút Xốp Không Gian
Mút Sofa Không Gian
Top Bottom