Items This Page

Items This Page 1.1.1

Нет прав на скачивание
Совместимость с XF
  1. 2.2.x
  2. 2.3.x
Краткое описание
Enhance your forum experience with our template variable that counts posts/media items. Adjust sidebar elements based on content length for a cleaner look. Simplify conditional logic using $xf.reply.templateParent for more efficient code. Hide ads when there's no content, even at the PAGE_CONTAINER level.
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.
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'
               ]) && $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:
HTML:
    <xf:if is="$xf.reply.templateParent == 'thread_view' && $xf.itemsThisPage <= 1">
        <!-- show nothing -->
    <xf:else />
        <!-- show the item -->
    </xf:if>

Hiding ads when there is no content

I use the following code on PropertyChat to hide adverts when there is no content on the page:
HTML:
<xf:if is="$xf.itemsThisPage === 0">
    <!-- show nothing -->
<xf:else />
    <!-- show the item -->
</xf:if>

... we can do this even on PAGE_CONTAINER level adverts because if $xf.itemsThisPage is not defined it will simply return null ... so by using $xf.itemsThisPage === 0 we can say "if it is defined and is actually equal to zero, then do this" ... while still doing something else on pages where it hasn't been defined and thus returns null.
Автор
axtona
Просмотры
207
Тип расширения
zip
Размер файла
14.4 КБ
Первый выпуск
Последнее обновление
Оценки 0.00 звезды 0 оценок
Ссылка не работает? Отправить сообщение команде NP, и мы поможем вам очень быстро!
Поддержите разработчика Если вы довольны тестом или ваш проект приносит доход, нажмите кнопку «Больше информации», чтобы поддержать разработчика покупкой.

Больше Ресурсов от axtona

Reactions Restriction A
allows you to restrict the use of certain reactions to specific content types or specific forums.
Просмотры
11
Обновлено
 Глобальные теги Клуб A
Перевести форумы тегов в статуированный интерактивный 3D визуальный опыт.
Просмотры
241
Обновлено
 Удалить пользователей A
Авто удаление пользователей в зависимости от настроек на странице опций.
Просмотры
48
Обновлено

Похожие ресурсы

[AndyB] Country restricted page A
Allows page access only to countries specified in options page.
Просмотры
443
Обновлено
[AndyB] Page view count A
This add-on is useful to see how many times your forum is viewed.
Просмотры
335
Обновлено
[AndyB] Page background manager A
Automatically rotates page background.
Просмотры
364
Обновлено
Назад
Вверх