Template Parent

Template Parent 1.0.1

没有下载权限
XF 兼容性
  1. 2.3.x
  2. 2.2.x
摘要
Add a new template variable in XenForo 2.2 to simplify conditional checks for threadview and forumview templates, reducing code complexity with an easier if statement.
Adds a new template variable $xf.reply.templateParent which groups all thread_view* and forum_view* templates together.

XenForo 2.2 adds multiple variations to the thread_view and forum_view templates for the various new thread types:

  • 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
So now when you want to target a template conditional to a thread view page (for example, in an advert), instead of previously doing the following:
HTML:
<xf:if is="$xf.reply.template == 'thread_view'">
    <!-- do something -->
</xf:if>


... we must now do this:

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>

An easier way

This addon adds a new template variable we can use to check if the template "parent" is thread_view or forum_view, so we can simply do the following instead to target all templates of that type:
HTML:
<xf:if is="$xf.reply.templateParent == 'thread_view'">
    <!-- do something for any thread view pages -->
</xf:if>
... or:
HTML:
<xf:if is="$xf.reply.templateParent == 'forum_view'">
    <!-- do something for any forum view pages -->
</xf:if>

Note that v1.0.1 or higher is required for XF 2.3 compatibility.
作者
axtona
浏览
228
扩展类型
zip
文件大小
11.6 KB
首次发布
上次更新
评分 0.00 星 0 个评分
链接失效了吗? 发送消息 给 NP 团队,我们会尽快为您处理!
支持开发者 如果您对测试满意或项目已成功盈利,可点击「更多信息」按钮,通过购买来支持开发者!

来自 axtona 的更多资源

[XFSkins] Thread Rating A
Topic Rating plugin adds a clean and easy-to-understand star rating system to XenForo topics
资产管理者 A
资产管理器为XenForo管理员提供了一种可视化和组织化的管理图片的方式
[FF] Login Spaminator Admin Area Logs A
Simple mod that allows you to browse the Spaminator logs from inside the admin area

相似的资源

 允许模板修改 A
作为你知道的,开发人员在2.1.8版本中决定抓住这个机会。
浏览
306
已更新
[OzzModz] Overlay Data Template Context A
Adds template context data parameter to the overlay HTML (used for styling by our addons)
浏览
315
已更新
[OzzModz] Template Modification List Tweaks A
Very quick and dirty addon for anyone who may find it useful
浏览
563
已更新
返回
顶部