The forum of the forums
Would you like to react to this message? Create an account in a few clicks or log in to continue.

Private Message Number Count

5 posters

Go down

Solved Private Message Number Count

Post by FineryWorkshop February 11th 2015, 10:20 pm

Hello, so I am currently working on a website, and I am trying to make it where on my custom navigation bar it says "Messages: <number of messages you have>" I have my own custom navigation bar so I can't use the preset one where it says "you have no new messages" or "you have new messages" 

Idk if it requires JS but yah. If anyone knows what to do please help Smile


Now solved. Thank you sooo much Wagner!


Last edited by FineryWorkshop on February 13th 2015, 2:11 am; edited 1 time in total
FineryWorkshop
FineryWorkshop
Forumember

Female Posts : 48
Reputation : 1
Language : English
Location : USA

http://NOTREADY.forumotion.com

Back to top Go down

Solved Re: Private Message Number Count

Post by Wagner' February 11th 2015, 11:04 pm

Which is the link of the image to unread messages of your forum? This need to be different than the read messages.. So we can do a request to this page "/privmsg?folder=inbox" and check how many images are there...
Wagner'
Wagner'
Forumember

Male Posts : 48
Reputation : 6
Language : Portuguese
Location : Brazil

http://www.bestskins.net/forum

Back to top Go down

Solved Re: Private Message Number Count

Post by FineryWorkshop February 12th 2015, 1:00 am

Wagner' wrote:Which is the link of the image to unread messages of your forum? This need to be different than the read messages.. So we can do a request to this page "/privmsg?folder=inbox" and check how many images are there...
What? XD It's not an image. Like I said above, I made my own navigation menu.
FineryWorkshop
FineryWorkshop
Forumember

Female Posts : 48
Reputation : 1
Language : English
Location : USA

http://NOTREADY.forumotion.com

Back to top Go down

Solved Re: Private Message Number Count

Post by TheCrow February 12th 2015, 2:56 am

Wagner' wrote:Which is the link of the image to unread messages of your forum? This need to be different than the read messages.. So we can do a request to this page "/privmsg?folder=inbox" and check how many images are there...
Hello,

@FineryWorkshop what Wagner is trying to say is that if you tell him the image you use for the unread messages in your inbox he could make the script to read how many messages are in your inbox. What you need to do is only send him the images and hopefully he can do it for you. He was not talking about the navigation bar images.. Wink

Luffy


Private Message Number Count Thecro10
Forum of the Forums

Forumotion Rules | Tips & Tricks |
FAQ | Did you forget your password?



*** The Support Forum will never ask you for your email or password, so please do not post them anywhere! ***
No support via PM!
TheCrow
TheCrow
Manager
Manager

Male Posts : 6916
Reputation : 795
Language : Greek, English

https://www.inforumgr.com

Back to top Go down

Solved Re: Private Message Number Count

Post by FineryWorkshop February 12th 2015, 4:54 am

Luffy wrote:
Wagner' wrote:Which is the link of the image to unread messages of your forum? This need to be different than the read messages.. So we can do a request to this page "/privmsg?folder=inbox" and check how many images are there...
Hello,

@FineryWorkshop what Wagner is trying to say is that if you tell him the image you use for the unread messages in your inbox he could make the script to read how many messages are in your inbox. What you need to do is only send him the images and hopefully he can do it for you. He was not talking about the navigation bar images.. Wink

Luffy
Ohhh Thank you XD
FineryWorkshop
FineryWorkshop
Forumember

Female Posts : 48
Reputation : 1
Language : English
Location : USA

http://NOTREADY.forumotion.com

Back to top Go down

Solved Re: Private Message Number Count

Post by FineryWorkshop February 12th 2015, 5:00 am

Wagner' wrote:Which is the link of the image to unread messages of your forum? This need to be different than the read messages.. So we can do a request to this page "/privmsg?folder=inbox" and check how many images are there...
Here Smile If you can do it thank you so much! I'll be sure to add you on the credit page.

Private Message Number Count Offlin10
https://i.servimg.com/u/f38/18/44/35/81/offlin10.png
Private Message Number Count Online10
https://i.servimg.com/u/f38/18/44/35/81/online10.png

And I'll be able to edit the script to change the images if I update them, right?
FineryWorkshop
FineryWorkshop
Forumember

Female Posts : 48
Reputation : 1
Language : English
Location : USA

http://NOTREADY.forumotion.com

Back to top Go down

Solved Re: Private Message Number Count

Post by Ikerepc February 12th 2015, 12:14 pm

Go to acp -> display -> pics managment -> simple mode

And edit it for private messages and new private messages.
Ikerepc
Ikerepc
Active Poster

Male Posts : 1187
Reputation : 167
Language : Who cares...
Location : Where web help & support is needed

http://admins.forumotion.com

Back to top Go down

Solved Re: Private Message Number Count

Post by Wagner' February 12th 2015, 12:58 pm

@Luffy,

Thank you! I'm learning english by my own, so I'm not so good at this moment.




@FineryWorkshop,

Yes, of course you'll be able to edit as you want. Check this script:

Code:
// Make the request to the inbox folder and store the content on the "data" variable.
$.get('/privmsg?folder=inbox', function(data) {

   // Here you can update the unread messages link.
   var unread_image = 'http://i38.servimg.com/u/f38/18/44/35/81/offlin10.png';
   // Here we store the number of unread messages.
   var unread = $('.main-content .status img[src="' + unread_image + '"]', data).length;
   
   // And here, we can use this number as we want...

   // If unread messages are greater than 0, do something.
   if( unread > 0 ) {
      // Here you need to edit the element you want to display that number.
      // For example: $('#my_element').text( unread );
      // As I don't know your page link, i'll just add an example
      alert('You have ' + unread + 'unread messages.');
   }
});

I've commented all the code, to maintain it clear to understand..

Look this part of the code
Code:
alert('You have ' + unread + 'unread messages.');

See this "unread" variable? This is what you'll use to display how many unread messages exists for the user. If you don't know how to do this, just send me your forum link..

And, I don't know your forum version too, i've made this code to work on PunBB, idk if it will work on other versions.

Test it cheers
Wagner'
Wagner'
Forumember

Male Posts : 48
Reputation : 6
Language : Portuguese
Location : Brazil

http://www.bestskins.net/forum

Back to top Go down

Solved Re: Private Message Number Count

Post by FineryWorkshop February 12th 2015, 2:36 pm

@Wagner' Should I add the script in my template for the Messages or in my JS Codes or in both?
FineryWorkshop
FineryWorkshop
Forumember

Female Posts : 48
Reputation : 1
Language : English
Location : USA

http://NOTREADY.forumotion.com

Back to top Go down

Solved Re: Private Message Number Count

Post by Wagner' February 12th 2015, 3:27 pm

You need to add to the page you're editing, but. Keep in mind that exists something called same-origin policy (read about this here: https://developer.mozilla.org/en-US/docs/Web/Security/Same-origin_policy).
Wagner'
Wagner'
Forumember

Male Posts : 48
Reputation : 6
Language : Portuguese
Location : Brazil

http://www.bestskins.net/forum

Back to top Go down

Solved Re: Private Message Number Count

Post by FineryWorkshop February 12th 2015, 9:57 pm

Nothing happened when I put the script in :/
FineryWorkshop
FineryWorkshop
Forumember

Female Posts : 48
Reputation : 1
Language : English
Location : USA

http://NOTREADY.forumotion.com

Back to top Go down

Solved Re: Private Message Number Count

Post by FineryWorkshop February 12th 2015, 10:52 pm

Idk if I did it wrong though. I added the script into the area I wanted the number of how many new PMs the member currently has.
FineryWorkshop
FineryWorkshop
Forumember

Female Posts : 48
Reputation : 1
Language : English
Location : USA

http://NOTREADY.forumotion.com

Back to top Go down

Solved Re: Private Message Number Count

Post by TheCrow February 13th 2015, 12:01 am

Have you added the
Code:
<script></script>
tags at the beginning and and at the end of the code?


Private Message Number Count Thecro10
Forum of the Forums

Forumotion Rules | Tips & Tricks |
FAQ | Did you forget your password?



*** The Support Forum will never ask you for your email or password, so please do not post them anywhere! ***
No support via PM!
TheCrow
TheCrow
Manager
Manager

Male Posts : 6916
Reputation : 795
Language : Greek, English

https://www.inforumgr.com

Back to top Go down

Solved Re: Private Message Number Count

Post by FineryWorkshop February 13th 2015, 12:23 am

Luffy wrote:Have you added the
Code:
<script></script>
tags at the beginning and and at the end of the code?
Yes Smile
FineryWorkshop
FineryWorkshop
Forumember

Female Posts : 48
Reputation : 1
Language : English
Location : USA

http://NOTREADY.forumotion.com

Back to top Go down

Solved Re: Private Message Number Count

Post by FineryWorkshop February 13th 2015, 1:31 am

@Wagner' You mentioned the "unread" as a forum variable but what do I put there instead?
FineryWorkshop
FineryWorkshop
Forumember

Female Posts : 48
Reputation : 1
Language : English
Location : USA

http://NOTREADY.forumotion.com

Back to top Go down

Solved Re: Private Message Number Count

Post by Wagner' February 13th 2015, 1:33 am

Can you send the link of the page, please? And tell me where you want to display this infos.
Wagner'
Wagner'
Forumember

Male Posts : 48
Reputation : 6
Language : Portuguese
Location : Brazil

http://www.bestskins.net/forum

Back to top Go down

Solved Re: Private Message Number Count

Post by FineryWorkshop February 13th 2015, 1:37 am

Wagner' wrote:Can you send the link of the page, please? And tell me where you want to display this infos.
I sent it in a PM, I hope that's okay
FineryWorkshop
FineryWorkshop
Forumember

Female Posts : 48
Reputation : 1
Language : English
Location : USA

http://NOTREADY.forumotion.com

Back to top Go down

Solved Re: Private Message Number Count

Post by Wagner' February 13th 2015, 1:55 am

Here, this should work study

Code:
$(function() {
   $.get('/privmsg?folder=inbox', function(data) {

     var unread_image = 'http://i38.servimg.com/u/f38/18/44/35/81/offlin10.png';
     var unread = $('.main-content .status img[src="' + unread_image + '"]', data).length;
    
       $('.navbar ul li ul li a[href="http://fineryworkshop.forumotion.com/privmsg?folder=inbox"]').append(unread);
   });
});

rock
Wagner'
Wagner'
Forumember

Male Posts : 48
Reputation : 6
Language : Portuguese
Location : Brazil

http://www.bestskins.net/forum

Back to top Go down

Solved Re: Private Message Number Count

Post by FineryWorkshop February 13th 2015, 2:05 am

Wagner' wrote:Here, this should work study

Code:
$(function() {
   $.get('/privmsg?folder=inbox', function(data) {

      var unread_image = 'http://i38.servimg.com/u/f38/18/44/35/81/offlin10.png';
      var unread = $('.main-content .status img[src="' + unread_image + '"]', data).length;
     
       $('.navbar ul li ul li a[href="http://fineryworkshop.forumotion.com/privmsg?folder=inbox"]').append(unread);
   });
});

rock
Okay, so I put it in and it added that I have 0 PMs but when I sent myself one from a different account it didn't pop up for me? It still stayed 0  Sad
FineryWorkshop
FineryWorkshop
Forumember

Female Posts : 48
Reputation : 1
Language : English
Location : USA

http://NOTREADY.forumotion.com

Back to top Go down

Solved Re: Private Message Number Count

Post by Wagner' February 13th 2015, 2:07 am

Sorry, i forgot to adapt the selectors to your forum, here, this will work:

Code:
$(function() {
   $.get('/privmsg?folder=inbox', function(data) {

     var unread = $('ul.pmlist li dl[style="background-image: url(http://2img.net/i/fa/prosilver/topic_unread.gif);"]', data).length;
    
       $('.navbar ul li ul li a[href="http://fineryworkshop.forumotion.com/privmsg?folder=inbox"]').append(unread);
   
   });
});
Wagner'
Wagner'
Forumember

Male Posts : 48
Reputation : 6
Language : Portuguese
Location : Brazil

http://www.bestskins.net/forum

Back to top Go down

Solved Re: Private Message Number Count

Post by FineryWorkshop February 13th 2015, 2:10 am

Wagner' wrote:Sorry, i forgot to adapt the selectors to your forum, here, this will work:

Code:
$(function() {
   $.get('/privmsg?folder=inbox', function(data) {

      var unread = $('ul.pmlist li dl[style="background-image: url(http://2img.net/i/fa/prosilver/topic_unread.gif);"]', data).length;
     
       $('.navbar ul li ul li a[href="http://fineryworkshop.forumotion.com/privmsg?folder=inbox"]').append(unread);
   
   });
});
Omg, it works! Thank you SO much for your help ♥ Laughing
FineryWorkshop
FineryWorkshop
Forumember

Female Posts : 48
Reputation : 1
Language : English
Location : USA

http://NOTREADY.forumotion.com

Back to top Go down

Solved Re: Private Message Number Count

Post by Wagner' February 13th 2015, 2:13 am

We're here to help Very good

Just, don't forget, this link "https://2img.net/i/fa/prosilver/topic_unread.gif" need always to be the same link on the admin panel to unread messages... So, if you update the link on the panel, don't forget to update it on the code too.

Best regards Zen
Wagner'
Wagner'
Forumember

Male Posts : 48
Reputation : 6
Language : Portuguese
Location : Brazil

http://www.bestskins.net/forum

Back to top Go down

Solved Re: Private Message Number Count

Post by FineryWorkshop February 13th 2015, 2:27 am

I will! Thank you :3

And to moderators, whenever you see this it's fine to lock it now ♥
FineryWorkshop
FineryWorkshop
Forumember

Female Posts : 48
Reputation : 1
Language : English
Location : USA

http://NOTREADY.forumotion.com

Back to top Go down

Solved Re: Private Message Number Count

Post by _Twisted_Mods_ February 13th 2015, 4:12 am

Thank you everyone who helped with this topic

Topic solved and archived
_Twisted_Mods_
_Twisted_Mods_
Helper
Helper

Male Posts : 2083
Reputation : 336
Language : English
Location : Ms

http://liquidcode.forumotion.com

Back to top Go down

Back to top

- Similar topics

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