• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

XF 1.5 How to build the "sum" of item counts in a popup from different add-ons

Freelancer

Well-known member
#1
In my style that I use, the different report counts from different add-ons need to be summarized in one "total" count in the popup menu in the moderator bar. I want to add up "Reports Count", "Tickets Count" and "ModEss Log Count" to one sum. How to I achieve this? What variables are used?

In addition, how do I achieve to have the "0" (zero) counts be in a different color/class (I guess with "if" conditional statements and the variable – but how?)

Before someone says "that's UI.X, ask Audentio/Themehouse"... I already did and they said: it is a XF core functionality.

Cheers

uix_count.jpg
 

Steve F

Well-known member
#2
You can use this to guide you I think.

navigation_visitor_tab template

HTML:
<xen:set var="$visitorHiddenUnread" value="{xen:calc '{$visitor.alerts_unread} + {$visitor.conversations_unread}'}" />
        <a href="{xen:link account}" class="navLink accountPopup NoPopupGadget" rel="Menu"><strong class="accountUsername">{$visitor.username}</strong>
            <strong class="itemCount ResponsiveOnly {xen:if $visitorHiddenUnread, '', 'Zero'}"
                id="VisitorExtraMenu_Counter">
                <span class="Total">{xen:number $visitorHiddenUnread}</span>
                <span class="arrow"></span>
            </strong>
        </a>
Basically use the xen:set to set the variable of the sum of your items. Then you use that var in the menu link count.
 

Freelancer

Well-known member
#4
I love when a plan comes together. Thanks again for the right tip @Steve F ! (y)
For everyone who has the same demands for correct user experience and who wants to improve their UI.X theme in conjunction with third party add-ons I want to write everything down here:

Themehouse UI.X "Moderation Bar" enhancement for item counts in responsive mode:

In template "moderator_bar" find the section below <xen:if is="@uix_adminMenuCollapse != '0'">

FIND
Code:
<li class="navTab admin Popup PopupControl PopupClosed">

            <a href="<xen:if is="{$visitor.is_admin}">admin.php<xen:else />javascript: void(0);</xen:if>" class="navLink NoPopupGadget" rel="Menu" <xen:if is="{$visitor.is_admin}">target="_blank"</xen:if>>
                <i class="uix_icon uix_icon-admin"></i>
                <span class="itemLabel">{xen:if {$visitor.is_admin}, '{xen:phrase admin_control_panel_short}', '{xen:phrase uix_moderator_short}'}</span>
                <strong class="itemCount">
                    <span class="Total">0</span>
                    <span class="arrow"></span>
                </strong>
REPLACE WITH
Code:
<xen:set var="$moderatorHiddenUnread" value="{xen:calc '{$session.userModerationCounts.total} + {$session.reportCounts.total} + {$session.ticketCounts.total} + {$session.modLogCounts.total}'}" />

        <li class="navTab admin Popup PopupControl PopupClosed">
            <a href="<xen:if is="{$visitor.is_admin}">admin.php<xen:else />javascript: void(0);</xen:if>" class="navLink NoPopupGadget" rel="Menu" <xen:if is="{$visitor.is_admin}">target="_blank"</xen:if>>
                <i class="uix_icon uix_icon-admin"></i>
                <span class="itemLabel">{xen:if {$visitor.is_admin}, '{xen:phrase admin_control_panel_short}', '{xen:phrase uix_moderator_short}'}</span>
                <strong class="itemCount <xen:if is="{$moderatorHiddenUnread}">alert<xen:else /></xen:if>">
                    <span class="Total">{xen:number $moderatorHiddenUnread}</span>
                    <span class="arrow"></span>
                </strong>
IMPORTANT

"<xen:set var="$moderatorHiddenUnread" value="{xen:calc '{$session.userModerationCounts.total} + {$session.reportCounts.total} + {$session.ticketCounts.total} + {$session.modLogCounts.total}'}" />"
sets the variable "$moderatorHiddenUnread" which then must be placed in the <span> for the total, while the if-condition in the class "itemCount" either adds the class "alert" (for a red background) if variable is not "0" or adds nothing if "0".

Check which add-ons you have and delete those variables from the equation you don't have:
$session.userModerationCounts.total (Moderation Queue – XF Core)
$session.reportCounts.total (Reports Queue – XF Core)
$session.ticketCounts.total (@NixFifty Ticket add-on)
$session.modLogCounts.total (@Xon Moderator Essentials add-on)

To adjust the "Zero" item counts in the Admin/Moderator menu to the SAME CSS as they have in the non-responsive view, you need to...

...open template "uix_userBar.css" and FIND
Code:
#userBar .navTabs .navLink .itemCount
and

REPLACE WITH
Code:
#userBar .navTabs .navLink .itemCount,
.uix_adminMenu .blockLinksList .itemCount
I hope this finds some use with some of you.

UI.X Beauty:
uix_beauty.jpg
 
Last edited: