Items This Page

xF2 Beta Items This Page 1.1.0

No permission to download
Compatible XF Versions
  1. 2.1
  2. 2.2
Adds a new template variable $xf.itemsThisPage containing how many posts/media items/resources/etc. are shown on a page.

This is useful in templates if you want to adjust the display of some element based on how many posts or threads or media items there are displayed.

For example, you might want to hide an element from the sidebar on short threads (or on the last page of a thread where only one or two posts are shown), to prevent the sidebar from being much longer than the content.

Usage example:

The following code might be used in a sidebar ad placement to hide the advert on short thread pages.


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'
               ]) && $xf.itemsThisPage <= 1">
        <!-- show nothing -->
    <xf:else />
        <!-- show the item -->
    </xf:if>


An even easier way

If we combine this addon with the Template Parent addon, which gives us a shorthand way of referencing all of the various thread and forum types in template names using a new $xf.reply.templateParent template variable - we can simplify the above example even further:


Code:
 <xf:if is="$xf.reply.templateParent == 'thread_view' && $xf.itemsThisPage <= 1">
        <!-- show nothing -->
    <xf:else />
        <!-- show the item -->
    </xf:if>
Author
Admin
Size
12.3 KB
Extension
zip
Downloads
2
Views
1,172
First release
Last update

More resources from Admin

Latest updates

  1. v1.1.0 update - new templates

    new templates added: xfmg_watched_media whats_new_posts xfmg_whats_new_media...

Similar resources

Customize your 404 error page, keep track of missing URLs and redirect them to new pages.
0.00 star(s) 0 ratings
Downloads
31
Updated
Home Page Title AnimeHaxor
Set a custom title for the home page instead of boardTitle
0.00 star(s) 0 ratings
Downloads
10
Updated
[cXF] Hide profile page Admin
Hide profile page based on user group permission with a notice.
0.00 star(s) 0 ratings
Downloads
7
Updated
[cXF] Status update on What's new page Admin
Easily update your profile status on What's new page.
0.00 star(s) 0 ratings
Downloads
6
Updated
Allows you to specific page criteria using when using Xon's Browser Detection addon.
0.00 star(s) 0 ratings
Downloads
0
Updated