XF 2.2 Alerts, notification and ?

Robert9

Well-known member
I try to learn something about the small red badges we have in the navigation, when there is something new.

I understand that an alert is a small text with an info like /account/alerts
A notification cares for something equal per email.

But what is the name (and the typical name of the class that cares) for the badges in the navigation, please?
 
Yes, found some css in xml. But nothing else.
But still have no found any code for.

Is it possible that it is only:
add css/js into a template for the navTabs with an xf:if?
 
Last edited:
Yes, it looks like.


This is a part from the AMS

Code:
    public static function navigationSetup(\XF\Pub\App $app, array &$navigationFlat, array &$navigationTree)
    {
        if (isset($navigationFlat['xa_ams']) && self::visitor()->canViewAmsArticles() && \XF::options()->xaAmsUnreadCounter)
        {
            $session = $app->session();
    
            $articlesUnread = $session->get('amsUnreadArticles');
            
            if ($articlesUnread)
            {
                $navigationFlat['xa_ams']['counter'] = count($articlesUnread['unread']);
            }
        }
    }


This is a part from the XFMG

Code:
    public static function navigationSetup(\XF\Pub\App $app, array &$navigationFlat, array &$navigationTree)
    {
        if (isset($navigationFlat['xfmg']) && self::visitor()->canViewMedia() && \XF::options()->xfmgUnviewedCounter)
        {
            $session = $app->session();

            $mediaUnviewed = $session->get('xfmgUnviewedMedia');
            if ($mediaUnviewed)
            {
                $navigationFlat['xfmg']['counter'] = count($mediaUnviewed['unviewed']);
            }
        }
    }
 
So we only need ?

<listener event_id="navigation_setup" execute_order="10" callback_class="Autor\Addon\Listener" callback_method="navigationSetup" active="1"/>

and

public static function navigationSetup in Listener.php

This would be nice, i will try it in a minute. :)

Seems easy if we have a field like "unreadSomething" or a timestamp in our table.
 
Wow. It works and i really love it.

Is there something like {timestamp of my last session} before this session?

yes, xf_user.last_activity, very nice. :)
 
Last edited:
May someone has an idea about the strategy to know:

  • how many new followers since last login?
  • how many likes last last login?
  • how many {whatever} since last login?

I dont want to query these things in my new listener.

Maybe i should query them, when the session starts?
 
Top Bottom