How to get ALL itemCount alerts to show in one itemCount

Matthew Hawley

Well-known member
So basicly I want the moderation, reports, and users needing approval itemcount alerts, to show in one item count alert. This is what I tried

Code:
<span class="itemLabel">{xen:phrase moderation_queue_short}:</span><span class="itemCount {xen:if '({$session.moderationCounts.total} AND {$session.reportCounts.total} AND {$session.userModerationCounts.total}', 'alert'}">{$session.moderationCounts.total}</span></a>
Didn't work

I suspect @Kier and @Mike would know so lets send them an alert...
 
Last edited:

Sheldon

Well-known member
Relax, you only waited 20 minutes after posting to start tagging again. If someone knows, or can answer, I am certain they will.
 

Mike

XenForo developer
Staff member
Template editing questions go in the styling forum. Code related questions go in the dev forum.

You should use xen:calc to add the values.
 

Jake Bunce

XenForo moderator
Staff member
As Mike said, use xen:calc to get the total:

Code:
<xen:set var="$totalCounts">{xen:calc '{$session.userModerationCounts.total} + {$session.reportCounts.total} + {$session.moderationCounts.total}'}</xen:set>
Now you can use {$totalCounts} in the template.
 

Matthew Hawley

Well-known member
As Mike said, use xen:calc to get the total:

Code:
<xen:set var="$totalCounts">{xen:calc '{$session.userModerationCounts.total} + {$session.reportCounts.total} + {$session.moderationCounts.total}'}</xen:set>
Now you can use {$totalCounts} in the template.
Okay so, how would I use that in this?

Code:
<span class="itemCount {xen:if {$session.moderationCounts.total}, 'alert'}">{$session.moderationCounts.total}</span></a>                     
                                                        <div class="Menu">
I keep trying but I get errors.
 

MattW

Well-known member
Okay so, how would I use that in this?

Code:
<span class="itemCount {xen:if {$session.moderationCounts.total}, 'alert'}">{$session.moderationCounts.total}</span></a>                    
                                                        <div class="Menu">
I keep trying but I get errors.
There is only 1 variable in your code above, so what are you trying to add it to?
 

SneakyDave

Well-known member
Something like this perhaps? Just guessing.
Code:
<xen:set var="$totalCounts">{xen:calc '{$session.userModerationCounts.total} + {$session.reportCounts.total} + {$session.moderationCounts.total}'}</xen:set>
<span class="itemCount {xen:if {$totalCounts}, 'alert'}">{$totalCounts}</span></a>                     
                                                        <div class="Menu">
 

Matthew Hawley

Well-known member
Something like this perhaps? Just guessing.
Code:
<xen:set var="$totalCounts">{xen:calc '{$session.userModerationCounts.total} + {$session.reportCounts.total} + {$session.moderationCounts.total}'}</xen:set>
<span class="itemCount {xen:if {$totalCounts}, 'alert'}">{$totalCounts}</span></a>                    
                                                        <div class="Menu">
It worked thanks!
 
Top