XF 2.3 What is the error in this code?

webtiryaki

Active member
I am creating a plugin, forum statistics show correctly while online statistics return 0, what am I doing wrong?

PHP:
<div class="p-footer-row custom-forum-stats-wt">
    <div class="p-footer-inner">
        <div class="p-footer-content">
            <h3 class="p-footer-title">{{ phrase('forum_statistics') }}</h3>
            <ul class="list--separated custom-stats-list-wt">
                <li>{{ phrase('threads') }}: <span>{$xf.app.forumStatistics.threads|number}</span></li>
                <li>{{ phrase('messages') }}: <span>{$xf.app.forumStatistics.messages|number}</span></li>
                <li>{{ phrase('members') }}: <span>{$xf.app.forumStatistics.users|number}</span></li>
                <xf:if is="$xf.app.forumStatistics.latestUser">
                    <li>{{ phrase('latest_member') }}: <xf:username user="$xf.app.forumStatistics.latestUser" rich="true" /></li>
                </xf:if>
            </ul>

            <h3 class="p-footer-title" style="margin-top: 1em;">{{ phrase('online_statistics') }}</h3>
            <ul class="list--separated custom-stats-list-wt">
                <li>
                    {{ phrase('online_now_total') }}: <span>{$xf.session.onlineStats.total|number}</span>
                    (<span title="{{ phrase('members') }}">{{ phrase('members_abbr') }}: {$xf.session.onlineStats.members|number}</span>,
                    <span title="{{ phrase('guests') }}">{{ phrase('guests_abbr') }}: {$xf.session.onlineStats.guests|number}</span>
                    <xf:if is="$xf.session.onlineStats.robots">, <span title="{{ phrase('robots') }}">{{ phrase('robots_abbr') }}: {$xf.session.onlineStats.robots|number}</span></xf:if>)
                </li>
            </ul>
        </div>
    </div>
</div>

</footer>
 
In templates, $xf.session refers to the session object for the current visitor. If you want statistics on all sessions, you have to query for them (\XF\Repository\SessionActivityRepository::getOnlineStatsBlockData).
 
Back
Top Bottom