View Full Version : how to get a list of notifications
bradthor
12-28-2015, 01:51 AM
expounding on Markfl's answer given in the following getting the total number of notifications (https://vborg.vbsupport.ru/showthread.php?t=321168) and this thread Adding a notification. (https://vborg.vbsupport.ru/showthread.php?t=286095)how would I get a dynamic array of all the notifications or of each of the notification types in vbulletin so that I can create a dynamic list of notifications?
Also If there is any documentation about the various userinfo ,activity and notification types and the functions that are used to instantiate them that would be really helpful.
Thanks a ton in advance.
If you check the "user" table, you will see columns such as "vmunreadcount", "friendreqcount", etc. I think you can access those variables in the $vbulletin->userinfo array to then process them to your needs.
bradthor
12-28-2015, 02:08 AM
Thanks for the answer:)....how would I do this exactly?
MarkFL
12-28-2015, 02:40 AM
In my reply in the other thread, I think I gave you all of the notification types intrinsic to vB 4. You would then have to look at your "user" table to see if any of your installed products have added any of their own, such as "DragonByte Tech: Advanced Post Thanks / Like (Pro)" does.
Then once you have determined all of the notification types on your site, you would add them all up to get the total. :)
bradthor
12-28-2015, 12:11 PM
I dont need the total any more ...the message you sent hlped me figure that out ... I need to make a dynamic list from each of those so I can make a notifications list
--------------- Added 1451311925 at 1451311925 ---------------
I need to find out how to use those functions you mentioned to make a dynamic list
MarkFL
12-28-2015, 01:24 PM
Well, in your PHP code, you could do something like:
$notifications = '';
//Only display for non-zero values.
if ($vbulletin->userinfo['pmunread'])
{
$notifications .= 'Unread PMs: ' . $vbulletin->userinfo['pmunread'] . PHP_EOL;
}
//Check for other notifications in the same way.
Then you could wrap the $notifications string in the appropriate HTML before appending it to a template hook or you might have a custom template designed that you would simply register this string so it can by output there.
bradthor
12-28-2015, 02:20 PM
Well, in your PHP code, you could do something like:
$notifications = '';
//Only display for non-zero values.
if ($vbulletin->userinfo['pmunread'])
{
$notifications .= 'Unread PMs: ' . $vbulletin->userinfo['pmunread'] . PHP_EOL;
}
//Check for other notifications in the same way.
Then you could wrap the $notifications string in the appropriate HTML before appending it to a template hook or you might have a custom template designed that you would simply register this string so it can by output there.
Thanks for the reply BUT i noticed that perhaps I haven't explained what i'm trying to achieve properly.
I understand that $vbulletin->userinfo['pmunread'] fetches the number of "pmunread" notifications however lets say that there is 1 "pmunread" notification ,what would be the best way to go about retrieving information about this 1 "pmunread" notification eg:- pmtextid, messageread, fromusername, pmid and the associated (serialized) format for that notification type eg:-('user X has just messaged you Re:pmtext');
and then display that in a foreach loop which accounts for a dynamic list of notifications, just like the facebook notifications dropdown.
I hope this makes more sense.
Thanks again for the reply:)
You will have to query the pm/pmtext table in that case. As far as I know vBulletin doesn't provide a function or array that contains all the information you need.
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.