Who is online?
In total there are 3 users online :: 0 Registered, 0 Hidden and 3 Guests :: 1 Bot

None

[ View the whole list ]


Most users ever online was 246 on Tue 31 Jan - 2:47
Statistics
We have 150 registered users
The newest registered user is Luxic

Our users have posted a total of 2050 messages in 200 subjects
Latest topics
» A small share
by Flora Today at 21:03

» Edit the 404 page on Forumotion
by LGforum Today at 15:29

» How to Change The Homepage?
by LGforum Today at 15:28

» Counter for my notices box
by Niko Today at 15:03

» 21. Show Recent Topics Preview In Accordion
by ReBoRN Yesterday at 19:08

15. Visitor Message Notifications

Page 1 of 2 1, 2  Next

View previous topic View next topic Go down

15. Visitor Message Notifications

Post by LGforum on Sat 24 Dec - 0:08

15. Visitor Message Notifications
(for phpbb3 and invision, it might work in other versions... I didn't check)
- Example in the top left corner.


PLEASE NOTE: for this tutorial to work you must have installed this: http://www.diondesigns.org/t440-example-9-accessing-user-information-all-boards
That tutorial will create a global variable accessible to other scripts which contains the user id number.
UNLESS: if you have LGchat version 4 installed, you won't need to install the above link.


After doing so if not already installed... put this in a javascript file:
(i recommend putting this script ONLY FOR HOMEPAGE, NOT in all pages.)

Code:

var CopyrightNotice='Visitor Message Notification script for Forumotion Boards. Copyright © by LGforum. All Rights Reserved. Use and  modification of this script is not allowed without this entire copyright notice in the original, copied, or modified script. No distribution without consent.';

function getvms(){
var a=new XMLHttpRequest();
a.onreadystatechange=function() {
  if (a.readyState==4 && a.status==200)  {
      var x=a.responseText.indexOf('title="New message" /> by ');
      if (x != -1) {
        var c=a.responseText.substring(x,a.responseText.indexOf('</a>',x)+4);
        var user=c.substring(26,c.length);
        var html="<div id='LGnewVM'>Notification: '"+user+"' has left you a Visitor Message!<br><br><span onclick=\"document.getElementById('LGnewVM').style.display='none';\">Close</span></div>";
        document.body.innerHTML+=html;
      }
  }
}; a.open("GET","/u" +uid+ "wall",true); a.send();
}
$(function(){ if (uid){ getvms(); } else { setTimeout('getvms();',1500); }});


And then this goes in your CSS to style it. Feel free to make it look more like your forum.
Code:

#LGnewVM {
  position: fixed;
  top: 5px; right: 5px;
  border: 2px solid #105289;
  background: #fff;
  border-radius: 6px;
  font-size: 13px;
  text-align: center;
  padding: 10px;
}
#LGnewVM span {
  border: 1px solid #000;
  background: #CCC;
  color: #000;
  padding: 3px;
  cursor: pointer;
}
#LGnewVM span:hover {
  background: #666;
  color: #fff;
}


This script will provide you with a notification box in the top corner of the page when someone has posted a message on your wall (visitor messages).
It uses a similar technique to this forum, and will also grab the name of the person who has posted on your wall. (only the latest message)

Here's a screenshot of what it will look like:


I admit the styling is simple... but i reckon you'll like it when you see it on your page.

I understand a lot of forums don't use the visitors message feature much, but now with notifications, here's your chance to make use of this feature Wink

Notification: Admin has left you a Visitor Message!
Close


Last edited by LGforum on Tue 17 Jan - 5:53; edited 11 times in total

LGforum


Forum Version: Phpbb3
Posts: 729
Join date: 2011-10-05
Location: UK

View user profile http://www.avacweb.com

Back to top Go down

Re: 15. Visitor Message Notifications

Post by nutsonlizards on Sat 24 Dec - 9:24

Now This Is a nice Tutorial I tried it on phpBB2 and it don't seem to work which is a shame but I may now look into changing my forum over to phpBB3 Smile

nutsonlizards


Forum Version: PunBB
Posts: 44
Join date: 2011-11-18

View user profile

Back to top Go down

Re: 15. Visitor Message Notifications

Post by Flora on Sun 25 Dec - 3:33

This is definitely on my list to get done. Smile

Very nice tutorial, LG! Thank you! Smile

Flora


Status Status: If you like gardening, please join my site. Ty. :)
Forum Version: Phpbb3
Posts: 151
Join date: 2011-11-18
Location: USA

View user profile http://www.chlorisgarden.com

Back to top Go down

Re: 15. Visitor Message Notifications

Post by pidot101 on Mon 26 Dec - 9:40

Make some for phpbb2 Razz

pidot101

Status Status: . . .
Posts: 58
Join date: 2011-12-09
Age: 16

View user profile

Back to top Go down

Re: 15. Visitor Message Notifications

Post by Flora on Mon 26 Dec - 11:32

LG, I installed this, but have since taken it off because I think I might have another script running that might be clashing with it. I just couldn't get it to show up when visitor messages tests were performed. (And yes, I did install LG Chat V4.0 prior to applying this.)

So, until I find what the problem is, I'll have to pass on this. Sad

Flora


Status Status: If you like gardening, please join my site. Ty. :)
Forum Version: Phpbb3
Posts: 151
Join date: 2011-11-18
Location: USA

View user profile http://www.chlorisgarden.com

Back to top Go down

Re: 15. Visitor Message Notifications

Post by Urbrohasan on Mon 26 Dec - 13:01

its work on punbb?

Urbrohasan

Status Status: AVACWEB IS AWESOME
Forum Version: PunBB
Posts: 34
Join date: 2011-12-25
Age: 23
Location: Tamil nadu, India

View user profile

Back to top Go down

Re: 15. Visitor Message Notifications

Post by Flora on Mon 26 Dec - 14:07

LGforum wrote:15. Visitor Message Notifications
(for phpbb3 and invision, it might work in other versions... I didn't check)


Not sure Urbrohasan. I have phpbb3, though you could try it out and let us know how it goes. Smile

Flora


Status Status: If you like gardening, please join my site. Ty. :)
Forum Version: Phpbb3
Posts: 151
Join date: 2011-11-18
Location: USA

View user profile http://www.chlorisgarden.com

Back to top Go down

Re: 15. Visitor Message Notifications

Post by LGforum on Mon 26 Dec - 16:43

Flora, the problem is, the UID variable needed from LGchat script for ths script to work, is only available after the LGchat Iframe loads. (which i forgot)

You'll likely have more luck though if you put the script within script tags and stick it underneath your LGchat HTML.

If still no luck i could take a look at your forum.

EDIT: You'll now see in the top left corner of this page an example notice. I'm going to be doing with this with my tutorials from now on... if possible and needed.

LGforum


Forum Version: Phpbb3
Posts: 729
Join date: 2011-10-05
Location: UK

View user profile http://www.avacweb.com

Back to top Go down

Re: 15. Visitor Message Notifications

Post by Flora on Mon 26 Dec - 18:01

Ok LG. I'll give it another go. Thank you! Smile

Flora


Status Status: If you like gardening, please join my site. Ty. :)
Forum Version: Phpbb3
Posts: 151
Join date: 2011-11-18
Location: USA

View user profile http://www.chlorisgarden.com

Back to top Go down

Re: 15. Visitor Message Notifications

Post by Flora on Mon 26 Dec - 19:26

LGforum wrote:Flora, the problem is, the UID variable needed from LGchat script for ths script to work, is only available after the LGchat Iframe loads. (which i forgot)

You'll likely have more luck though if you put the script within script tags and stick it underneath your LGchat HTML.

If still no luck i could take a look at your forum.

EDIT: You'll now see in the top left corner of this page an example notice. I'm going to be doing with this with my tutorials from now on... if possible and needed.


Tried that, and it's still not working. Sorry.

Flora


Status Status: If you like gardening, please join my site. Ty. :)
Forum Version: Phpbb3
Posts: 151
Join date: 2011-11-18
Location: USA

View user profile http://www.chlorisgarden.com

Back to top Go down

Re: 15. Visitor Message Notifications

Post by ion-cube on Mon 26 Dec - 21:16

Code:

EDIT: You'll now see in the top left corner of this page an example notice. I'm going to be doing with this with my tutorials from now on... if possible and needed.

cool idea

ion-cube

Status Status: Testing
Posts: 121
Join date: 2011-10-19
Age: 23
Location: Pakistan

View user profile

Back to top Go down

Re: 15. Visitor Message Notifications

Post by LGforum on Sat 14 Jan - 14:27

I have edited the code in this tutorial for users who were having problems with it.

From what I have seen the users who were having the problems were the users who were using LGchat and so not the installation provided in the link.

The problem is coming from the fact that the script needs the unique user id number and it can get that from the LGchat script. However, this script is often running before the LGchat script, and so before the user id number is available and thats where the problem is.

So i've edited it to contain this line:
Code:

$(function(){ if (uid != 'undefined'){ getvms(); } else { setTimeout('getvms();',1500); });


Which will check if the user id is available, if it is it will run the function, if not then it will check again in a second. So as long as you either have the tutorial in the link installed or LGchat installed it should work fine now.

LGforum


Forum Version: Phpbb3
Posts: 729
Join date: 2011-10-05
Location: UK

View user profile http://www.avacweb.com

Back to top Go down

Re: 15. Visitor Message Notifications

Post by Flora on Sat 14 Jan - 17:09

I installed it again this afternoon. Nothing is conflicting with it as far as I can see. So I sent a VM, but have no notice of it yet, and not sure why.

I'll leave it as is so that you can see for yourself. Maybe we're missing something else? Not sure, but thank you for your help.

Flora


Status Status: If you like gardening, please join my site. Ty. :)
Forum Version: Phpbb3
Posts: 151
Join date: 2011-11-18
Location: USA

View user profile http://www.chlorisgarden.com

Back to top Go down

Re: 15. Visitor Message Notifications

Post by LGforum on Sat 14 Jan - 20:39

Apologies there was a tiny error. The script in the first post has been amended.

LGforum


Forum Version: Phpbb3
Posts: 729
Join date: 2011-10-05
Location: UK

View user profile http://www.avacweb.com

Back to top Go down

Re: 15. Visitor Message Notifications

Post by nutsonlizards on Sun 15 Jan - 16:41

Well Iv worked it out I think lol I used Dion Accessing User Information and it working like a treat thx Smile

nutsonlizards


Forum Version: PunBB
Posts: 44
Join date: 2011-11-18

View user profile

Back to top Go down

Page 1 of 2 1, 2  Next

View previous topic View next topic Back to top


Permissions in this forum:
You cannot reply to topics in this forum