模板父级

模板父级 1.0.1

No permission to download
XF Compatibility
  1. 2.3.x
  2. 2.2.x
添加了一个新的模板变量 $xf.reply.templateParent,将所有 thread_view* 和 forum_view* 模板都包含在一起。

XenForo 2.2 添加了多种变体的 thread_view 和 forum_view 模板,以适应各种新类型的帖子。
  • []*]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
那么现在如果你想针对一个模板条件来指向一个帖子查看页面(例如,在广告中),就不应该以前那样做:
HTML:
<xf:if is="$xf.reply.template == 'thread_view'">
    <!-- do something -->
</xf:if>
我们必须现在就做这件事:
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>
更简单的办法这个插件添加了一个新的模板变量,我们可以用来检查模板的“父”是否为thread_view 或 forum_view,这样我们就可以简单地这样做来针对所有该类型的模板:
HTML:
<xf:if is="$xf.reply.templateParent == 'thread_view'">
    <!-- do something for any thread view pages -->
</xf:if>
…… 或 :
HTML:
<xf:if is="$xf.reply.templateParent == 'forum_view'">
    <!-- do something for any forum view pages -->
</xf:if>
注意,v1.0.1或更高版本适用于XF 2.3兼容性。
Author
axtona
Views
234
Extension type
zip
File size
11.6 KB
First release
Last update
Ratings 0.00 star(s) 0 ratings
More resources from axtona
Using Composer Packages
Using Composer Packages
XenForo v2 uses Composer behind the scenes to include certain packages used by the core software
Eggy SEO Autopilot
Eggy SEO Autopilot
Automated auditing, metadata, structured data, Google Search Console, IndexNow
Cool Timeline Pro - WordPress 时间线插件
Cool Timeline Pro - WordPress 时间线插件
一个展示你生命历史时间线的高级WordPresstimeline插件
Back
Top