The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
||||
|
||||
(3) Instant Notifications in Page Title like Facebook
Using javascript and AJAX, we have implemented a system that updates notifications for likes, subscribed threads, and PM's in the page title, similar to Facebook. We use it on our site:
http://psychopathfree.com/forum.php It updates live, so even if they're visiting another site and the tab is sitting idle, they will see new notifications popup instantly. It's not very good coding, and I'm sure there is a better way to do it But if anyone would like this on their site, let me know. I would be happy to share our method. In the past day alone of enabling it, we've seen a 400+% increase in user engagement, new posts, new activity, and online users. |
Благодарность от: | ||
FTG LIQUID CL |
#2
|
|||
|
|||
Hi I checked your site but didn't find.
|
#3
|
||||
|
||||
Hey marc, the notifications will only show up for registered users who have a notification - I can post an example screenshot here:
|
#4
|
|||
|
|||
hi thanks..
which donate mod you are using? |
#5
|
|||
|
|||
I would like to have this!
|
Благодарность от: | ||
findingpeace |
#6
|
||||
|
||||
Hi FTG - which mods do you currently use that utilize the notifications system? (ie. Recent Thanks, Subscribed Thread Notifications, etc?)
Thanks |
#7
|
|||
|
|||
VSA advanced new post
Cel Social Groups Notifications |
#8
|
|||
|
|||
Woah, I'd love to have this.
I have DBTech Advanced Tagging and Thanks for Post (Hippy Fix) with Notifications. |
#9
|
||||
|
||||
Hi all,
Okay so here is the code I use, but it'll be different of course depending on what notifications mods you use. I would also definitely recommend getting the DBTech AJAX vbNotifications mod, since it will align perfectly with the instant title updates. It automatically detects & integrates both of the mods you guys have mentioned. Otherwise, users will be getting the (#) notification but still need to refresh the page to see it in the old vBulletin notifications bar. I have chosen to put it in FORUMHOME, FORUMDISPLAY, SHOWTHREAD, and USERCP_SHELL. You could do it in any template you want these to be visible. Just keep in mind, it operates on a 30 second Javascript timer, so it will partially boost your page requests. I definitely wouldn't put it in a global template (like footer or something). It needs to be placed somewhere in the head tag. Code:
<script type="text/javascript"> setInterval(function() { var data = "{vb:raw relpath}"; $.get(document.location.toString()).then(function (data){ //find and set the title of the page document.title = data.match(/<title>(.+)<\/title>/)[1]; }); }, 30000); setTimeout(function() { var data = "{vb:raw relpath}"; $.get(document.location.toString()).then(function (data){ //find and set the title of the page document.title = data.match(/<title>(.+)<\/title>/)[1]; }); }, 1000); </script> In each of these pages, you will also need to set the new initial Page Title. This will be different for each template you modify. For example, the Title element of USERCP_SHELL should be modified to look like this: Code:
<title><vb:if condition="$title_note_count">({vb:raw title_note_count}) </vb:if>{vb:raw pagetitle} - {vb:raw vboptions.bbtitle}</title> Now the part that will be different for everyone: $title_note_count This is the variable I'm pushing to my templates through a plugin / hook. It's the current total notification count. Depending on what mods you're using, your code will probably be different than mine. Here's an example of the plugin I use: Hook: process_templates_complete Execution Order: 5 Code:
global $vbulletin; $currentuserid = $vbulletin->userinfo[userid]; $query = "SELECT * FROM vbuser WHERE userid = $currentuserid"; $result = $vbulletin->db->query($query); while($row = $vbulletin->db->fetch_array($result)) { $a = $row['friendreqcount']; $b = $row['vmunreadcount']; $c = $row['socgroupinvitecount']; $d = $row['socgroupreqcount']; $e = $row['pcunreadcount']; $f = $row['vbseo_likes_unread']; $h = $row['pmunread']; $i = $row['recent_thankcnt']; } $title_note_count = $a + $b + $c + $d + $e + $f + $h + $i; vB_Template::preRegister('FORUMHOME',array('title_note_count' => $title_note_count)); vB_Template::preRegister('SHOWTHREAD',array('title_note_count' => $title_note_count)); vB_Template::preRegister('recent_thanks',array('title_note_count' => $title_note_count)); vB_Template::preRegister('FORUMDISPLAY',array('title_note_count' => $title_note_count)); vB_Template::preRegister('USERCP_SHELL',array('title_note_count' => $title_note_count)); vB_Template::preRegister('newthread',array('title_note_count' => $title_note_count)); vB_Template::preRegister('newreply',array('title_note_count' => $title_note_count)); Code:
$vbulletin->userinfo['notifications_total'] = $notifications_total; |
#10
|
|||
|
|||
I cant seem to get this to work.I dont use vbNotifications,where does the last piece of code go?
|
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|