inherit
217348
0
Jul 27, 2022 7:26:44 GMT -8
Lynx
5,849
January 2015
msg
|
Post by Lynx on Nov 18, 2016 16:30:27 GMT -8
I noticed that the proboards.dataHash will tell me if there are any new PM's (via has_new_messages), which does help in a project I'm working on. However, as this appears to just be a Boolean return, I tried searching to find out how many new PM's there were. So far, I've had no luck. Is this something that can't be pulled up from the dataHash? I'm looking for a way to actually get the number of new messages waiting to be read. Is it possible? Tagging some coders: Peter, Chris, Todge, Quozzo, ®i©hie, Brian, Ulises, Matej, Tim CamaraSorry for tagging so many, but hoping to be able to get a fairly quick response, as I've got the rest of the stuff done for the plugin this is needed for.
|
|
inherit
58740
0
Aug 20, 2024 7:29:21 GMT -8
®i©hie
I'm not very active here anymore thanks to my full-time job. - 12/27/23
14,036
September 2005
soe
|
Post by ®i©hie on Nov 18, 2016 16:35:13 GMT -8
To my knowledge no, because if so I would've done that in my pm alert plugin.
|
|
inherit
217348
0
Jul 27, 2022 7:26:44 GMT -8
Lynx
5,849
January 2015
msg
|
Post by Lynx on Nov 18, 2016 16:41:02 GMT -8
To my knowledge no, because if so I would've done that in my pm alert plugin. Bummer. Thanks for the response, ®i©hie. I was just curious because it looks like P̌̓aͧś̀t̀u͒le͆o͂2̀3̃̓ (I knew I forgot to tag someone in my first post - DORT!) did just that with his plugin (at least by looking at it in the library: www.proboards.com/library/plugins/item/1084 ).
|
|
inherit
The Dream Crusher (Ret.)
164921
0
Apr 1, 2014 11:00:25 GMT -8
Tim Camara
Teach a man to fish, etc., etc.
1,721
March 2011
tcamara
|
Post by Tim Camara on Nov 18, 2016 16:45:41 GMT -8
I mean, you could scrape it from the page, but afaik, there's not an officially supported way to do it.
|
|
inherit
58740
0
Aug 20, 2024 7:29:21 GMT -8
®i©hie
I'm not very active here anymore thanks to my full-time job. - 12/27/23
14,036
September 2005
soe
|
Post by ®i©hie on Nov 18, 2016 16:50:10 GMT -8
The only other option would be to require users to modify their themes templates to wrap a div around the pm total variable and give the div a class and grab it that way. Kinda like this:
<div class="pm_new">$[pm_new]</div>
Then use jquery to grab the number
$('.pm_new').html();
|
|
inherit
217348
0
Jul 27, 2022 7:26:44 GMT -8
Lynx
5,849
January 2015
msg
|
Post by Lynx on Nov 18, 2016 16:57:12 GMT -8
I mean, you could scrape it from the page, but afaik, there's not an officially supported way to do it. Hmm, this sounds like a possible request for V6 - or even post-V6 launch (sometime down the road)? Thanks for the reply, Tim!
|
|
inherit
217348
0
Jul 27, 2022 7:26:44 GMT -8
Lynx
5,849
January 2015
msg
|
Post by Lynx on Nov 18, 2016 16:59:40 GMT -8
The only other option would be to require users to modify their themes templates to wrap a div around the pm total variable and give the div a class and grab it that way. Kinda like this: <div class="pm_new">$[pm_new]</div> Then use jquery to grab the number $('.pm_new').html(); Wouldn't that then show the number of new PM's then, where they put it in their template? If so, maybe have style tags to use CSS to hide it from being displayed by the template?
|
|
#e61919
Product Manager
12218
0
1
Mar 11, 2017 17:47:30 GMT -8
Matej
This is my status!
17,630
August 2003
wooper
|
Post by Matej on Nov 18, 2016 17:16:26 GMT -8
Similar to ®i©hie solution; a quick and kinda dirty way for getting the number of new messages: Somewhere in the forum wrapper template: {foreach $[navigation.menu]} {if $[navigation.menu.notification.href] == "/conversation/recent"} <div class="new-message-counter" style="display: none;">$[navigation.menu.notification.total]</div> {/if} {/foreach}
In the JS: var newMessageCount = parseInt($('.new-message-counter').text(), 10);
(this might not work as intended, I just quickly wrote it up after seeing the notification)
|
|
inherit
217348
0
Jul 27, 2022 7:26:44 GMT -8
Lynx
5,849
January 2015
msg
|
Post by Lynx on Nov 18, 2016 17:24:54 GMT -8
I had tried this:
var nbrMsgs = parseInt($('tiptip_content').find('/\d+/').html());
but it came up with NaN. This is my first attempt with regex expressions, so I'm most likely doing something wrong. I was trying to get the number from the tip content. Maybe I need to find "Messages /\d+/" - but then, how to get the number?
|
|
#00AF33
Official Code Helper
19529
0
1
Nov 19, 2012 14:18:28 GMT -8
Todge
**
17,324
January 2004
todge
|
Post by Todge on Nov 18, 2016 18:33:22 GMT -8
You can grab it from the standard template with this..
var PMS = $("[href='/conversations']").find('.tip-number').html();
But whether that would work with updated templates could be pretty hit and miss.
|
|
Former Member
inherit
guest@proboards.com
225992
0
Nov 27, 2024 12:52:42 GMT -8
Former Member
0
January 1970
Former Member
|
Post by Former Member on Nov 18, 2016 19:54:29 GMT -8
The result is already loaded into your template
{if $[current_user.messages.new] > 0} <span>$[current_user.messages.new]</span> {/if}
|
|
inherit
217348
0
Jul 27, 2022 7:26:44 GMT -8
Lynx
5,849
January 2015
msg
|
Post by Lynx on Nov 19, 2016 6:54:51 GMT -8
You can grab it from the standard template with this.. var PMS = $("[href='/conversations']").find('.tip-number').html(); But whether that would work with updated templates could be pretty hit and miss. Thanks, Todge! I'll give that a try, as I'm hoping to keep it so users don't need to make any template changes. I'm definitely not dismissing ®i©hie's and Tim Camara's ideas though, as I like their ideas too. The result is already loaded into your template {if $[current_user.messages.new] > 0} <span>$[current_user.messages.new]</span> {/if} Thanks, @synthtec. The only problem with that is that template variables don't work in a JS component in a plugin. I'm actually trying to take the code I posted here and make it into a plugin.
|
|
inherit
217348
0
Jul 27, 2022 7:26:44 GMT -8
Lynx
5,849
January 2015
msg
|
Post by Lynx on Nov 19, 2016 12:42:11 GMT -8
You can grab it from the standard template with this.. var PMS = $("[href='/conversations']").find('.tip-number').html(); But whether that would work with updated templates could be pretty hit and miss. It certainly works on a vanilla theme, Todge. Thank you! Plugin now finished and support thread is here: support.proboards.com/thread/604881/notificationsI left this one editable, so people could adjust the styling and text if they wanted (since I was too lazy to add too many options into the UI - but I'll consider doing so if there's enough requests for that ). It's heavily commented for that purpose.
|
|
inherit
201984
0
Sept 11, 2023 1:23:07 GMT -8
P̌̓aͧś̀t̀u͒le͆o͂2̀3̃̓
Using My Talents Elsewhere
3,314
November 2013
pastuleo23
|
Post by P̌̓aͧś̀t̀u͒le͆o͂2̀3̃̓ on Dec 4, 2016 5:21:59 GMT -8
You can grab it from the standard template with this.. var PMS = $("[href='/conversations']").find('.tip-number').html(); But whether that would work with updated templates could be pretty hit and miss. It certainly works on a vanilla theme, Todge . Thank you! Plugin now finished and support thread is here: support.proboards.com/thread/604881/notificationsI left this one editable, so people could adjust the styling and text if they wanted (since I was too lazy to add too many options into the UI - but I'll consider doing so if there's enough requests for that ). It's heavily commented for that purpose. I hate template mods too. I just ripped the number from the tooltip in like a footer code and made a global variable. Like todge said. And if the theme was modded and said new messages in data hash but couldn't find tool tip, I made a generic, you have new messages appear
|
|