Template Parent

xF2 Beta Template Parent 1.0.0

No permission to download
Compatible XF Versions
  1. 2.1
  2. 2.2
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:

Code:
<xf:if is="$xf.reply.template == 'thread_view'">
    <!-- do something -->
</xf:if>


... we must now do this:


Code:
<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:


Code:
<xf:if is="$xf.reply.templateParent == 'thread_view'">
    <!-- do something for any thread view pages -->
</xf:if>


... or:


Code:
<xf:if is="$xf.reply.templateParent == 'forum_view'">
    <!-- do something for any forum view pages -->
</xf:if>
  • Like
Reactions: DannyRRR
Author
Admin
Size
12.3 KB
Extension
zip
Downloads
1
Views
1,466
First release
Last update

More resources from Admin

Similar resources

Master Style Alert - Highlight when you're editing a master template or master language AnimeHaxor
This alerts you when editing the master style by making the style selector bright red when selected
0.00 star(s) 0 ratings
Downloads
5
Updated
Mobile / Browser Detection in Template AnimeHaxor
0.00 star(s) 0 ratings
Downloads
1
Updated
0.00 star(s) 0 ratings
Downloads
24
Updated
[OzzModz] Overlay Data Template Context Admin
Adds template context data parameter to the overlay HTML
0.00 star(s) 0 ratings
Downloads
7
Updated
[OzzModz] Template Modification List Tweaks Admin
Collapse or expand modification groups, adds an icon for Search & Replace vs Regex
0.00 star(s) 0 ratings
Downloads
7
Updated