Notifications on external page using session + $notifications['unread_count']
Notifications on external page using session + $notifications['unread_count']
Hello fellow phpBB users,
This little thing has been bugging me for a couple of days. I sincerely love phpBB 3.1 new notifications system, and I really want to figure out a means to display the amount of unread notifications on my websites community page (outside of the forums).
I use the regular session integration and other features, such as using the $user->data['username'] for welcoming messages, and displaying if they have any unread mails with $user->data['user_unread_privmsg']. This all works absolutely perfectly (yay for phpBB as CMS, absolutely brilliant).
However, I haven't been able to find the name (if it actually is there), for unread notifications. I've tried a huge amount of variations on $user->data['user_notifications_unread_count']. I know user_notify exists, but I doubt this is the one I'm looking for - since it's been there since before 3.1 so I thought it might be used for something different entirely. Although I've also tried variations on that. Right now I'm down to about 87 different variations I've tried.
I'm really hoping somebody here knows how to show the amount of unread notifications using the above format.
Hope you guys can help me out!
This little thing has been bugging me for a couple of days. I sincerely love phpBB 3.1 new notifications system, and I really want to figure out a means to display the amount of unread notifications on my websites community page (outside of the forums).
I use the regular session integration and other features, such as using the $user->data['username'] for welcoming messages, and displaying if they have any unread mails with $user->data['user_unread_privmsg']. This all works absolutely perfectly (yay for phpBB as CMS, absolutely brilliant).
However, I haven't been able to find the name (if it actually is there), for unread notifications. I've tried a huge amount of variations on $user->data['user_notifications_unread_count']. I know user_notify exists, but I doubt this is the one I'm looking for - since it's been there since before 3.1 so I thought it might be used for something different entirely. Although I've also tried variations on that. Right now I'm down to about 87 different variations I've tried.
I'm really hoping somebody here knows how to show the amount of unread notifications using the above format.
Hope you guys can help me out!
Last edited by extricate on Tue Mar 31, 2015 3:01 pm, edited 1 time in total.
- DavidIQ
- Customisations Team Leader
- Posts: 1904
- Joined: Thu Mar 02, 2006 4:29 pm
- Location: Earth
- Contact:
Re: Notifications on external page using session + $user->data['notify']
It's actually a little more complex than that. The code you're wanting will look something like this:
Code: Select all
$phpbb_notifications = $phpbb_container->get('notification_manager');
$notifications = $phpbb_notifications->load_notifications(array(
'all_unread' => true,
));
$template->assign_vars(array('NOTIFICATIONS_COUNT' => ($notifications !== false) ? $notifications['unread_count'] : 0,));
Re: Notifications on external page using session + $user->data['notify']
Ah yea, I expected that much. I'll try to play with your code - I did notice the notification manager bit in the phpbb functions and tried to play with that but sadly my knowledge of PHP is lacking.
Thanks!
Thanks!
Re: Notifications on external page using session + $user->data['notify']
Okay, I managed it to return a 0, however it doesn't return the actual amount of unread notifications. My code looks as following now:
Up in the header, and...
... to return the actual value
What am I missing?
Any help is much appreciated!
Code: Select all
$phpbb_notifications = $phpbb_container->get('notification_manager');
$notifications = $phpbb_notifications->load_notifications(array(
'all_unread' => true,
));
$template->assign_vars(array('NOTIFICATIONS_COUNT' => ($notifications !== false) ? $notifications['unread_count'] : 0,));
Code: Select all
<span>. $notifications['unread_count'] . ' notifications.</a></span>
What am I missing?
Any help is much appreciated!
- DavidIQ
- Customisations Team Leader
- Posts: 1904
- Joined: Thu Mar 02, 2006 4:29 pm
- Location: Earth
- Contact:
Re: Notifications on external page using session + $user->data['notify']
Change
all_unread
to count_unread
. Everything else should stay the same.Re: Notifications on external page using session + $user->data['notify']
Thanks for your reply, I've tried the change but sadly:
and ...
... still only returns a 0, even though I still have 2 unread notifications.
Edit: posted wrong code here, corrected code still doesn't work.
Code: Select all
$phpbb_notifications = $phpbb_container->get('notification_manager');
$notifications = $phpbb_notifications->load_notifications(array(
'count_unread' => true,
));
$template->assign_vars(array('NOTIFICATIONS_COUNT' => ($notifications !== false) ? $notifications['unread_count'] : 0,));
Code: Select all
Je hebt ' . $notifications['unread_count'] . ' notificaties.
Edit: posted wrong code here, corrected code still doesn't work.
Re: Notifications on external page using session + $user->data['notify']
<span>{NOTIFICATIONS_COUNT} notifications.</span>
Do not hire Christian Bullock he won't finish the job and will keep your money
Re: Notifications on external page using session + $user->data['notify']
Thanks for your input.RMcGirr83 wrote:<span>{NOTIFICATIONS_COUNT} notifications.</span>
Sadly, I have yet to figure out a way to make hooks work on an external page.
Perhaps it's easier for you to understand what I'm trying to do when actually watching the page I'm trying to get it to work on: http://www.veiligheidscommunity.nl/
I'm trying to convert phpBB to be a CMS to run my entire website. Trying to understand basic concepts like this one is quite mandatory for me to succeed, and trying to understand the new notification system is only one step in that process... and a tough one at that, heh.
- DavidIQ
- Customisations Team Leader
- Posts: 1904
- Joined: Thu Mar 02, 2006 4:29 pm
- Location: Earth
- Contact:
Re: Notifications on external page using session + $user->data['notify']
Thought this would have been a quick answer but since it wasn't I have to now let you know that the proper location for this type of discussion is here.
Thanks.
Thanks.
Re: Notifications on external page using session + $user->data['notify']
Ah, I thought considering I'm not writing an extension, I thought this would've been the appropriate location.
Thanks for referring me. Could you mayhaps be so kind as to move the actual thread?
Thanks for referring me. Could you mayhaps be so kind as to move the actual thread?