Display a notification alert in a custom template location

Hello.

I have been trying to figure out how hivepress goes about adding the red circle with a number inside, suggesting to the user that they have unread messages and what not, but haven’t found out how it is done. <small class="hp-menu__item small>"

I am trying to display this notification in a custom place, and I probably could do it with some sloppy javascript looking for the element mentioned above, but I figured maybe I could try to understand how it is implemented in hivepress, and use this way to my success.

Thank you :slight_smile:

Hi,

With this code, you can get the number of notifications hivepress()->request->get_context(‘notice_count’).
You can view the styles through the Developer console, for example, create a test user and send a message to the admin, log in through the admin, and view these styles in the console.

Thanks for helping out.

Does this return the number of notices currently for the active user? Can I use it in like this:

if (hivepress()->request->get_context('notice_count') !== "0") {
// Show notice indicator
};

Currently unavailable to test, but I’ll try when I get back home.

You can just check it for “true” if there’s an empty value it will not pass:

if (hivepress()->request->get_context('notice_count')) {
// Show notice indicator
}
1 Like

Thank you. Work wonders

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.