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.

Code for number of unread PMs

3 posters

Go down

Solved Code for number of unread PMs

Post by ian2000 April 13th 2015, 1:08 am

Greetings! I have my own custom NAV bar Live demo here and I was wondering if it was possible to put a piece of code that would return the number of messages a user has. Right now my NAV bar just says "Messages" but I want to make it say something like "Messages (2)" or something? Is that possible?

Best,
Ian


Last edited by ian2000 on April 13th 2015, 3:16 am; edited 1 time in total
avatar
ian2000
Forumember

Posts : 42
Reputation : 3
Language : English

https://forum.somiibo.com

Back to top Go down

Solved Re: Code for number of unread PMs

Post by Ange Tuteur April 13th 2015, 1:49 am

Hey,

Did you delete {GENERATED_NAV_BAR} from the overall_header template ?
Ange Tuteur
Ange Tuteur
Forumaster

Male Posts : 13207
Reputation : 3000
Language : English & 日本語
Location : Pennsylvania

https://fmdesign.forumotion.com

Back to top Go down

Solved Re: Code for number of unread PMs

Post by ian2000 April 13th 2015, 2:01 am

Ange Tuteur wrote:Hey,

Did you delete {GENERATED_NAV_BAR} from the overall_header template ?

Thank you for the quick reply. I did delete that {GENERATED_NAV_BAR} element. My nav bar is done completely manually.

Here is the code for my nav bar (inside overall_header)
Spoiler:

And just in case here is the entire code for overall_header
Spoiler:
avatar
ian2000
Forumember

Posts : 42
Reputation : 3
Language : English

https://forum.somiibo.com

Back to top Go down

Solved Re: Code for number of unread PMs

Post by Ange Tuteur April 13th 2015, 2:04 am

The original navbar would need to be available so we can check the message link innerHTML. Add this to the template :
Code:
<div id="fa_navbar" style="display:none">{GENERATED_NAV_BAR}</div>
Ange Tuteur
Ange Tuteur
Forumaster

Male Posts : 13207
Reputation : 3000
Language : English & 日本語
Location : Pennsylvania

https://fmdesign.forumotion.com

Back to top Go down

Solved Re: Code for number of unread PMs

Post by ian2000 April 13th 2015, 2:21 am

Okay I added that and positioned it right above the code for my navbar. Is the code for accessing the innerHTML something I can have help with?

Thanks,
Ian
avatar
ian2000
Forumember

Posts : 42
Reputation : 3
Language : English

https://forum.somiibo.com

Back to top Go down

Solved Re: Code for number of unread PMs

Post by ian2000 April 13th 2015, 3:16 am

Fixed it! 

With no messages:
Code for number of unread PMs With_n10

With one new messge:
Code for number of unread PMs Withms10

Code:
         <li id="button_demo">
         
               <a class="firstlevel" href="/profile?change&mode=editprofile">
                  <span class="firstlevel">My Account<b id='mainAcc'></b></span>
               </a>
               
                                <ul>
                                           <!--i_icon_mini_new_message-->
                                          
                  <li>
                                                  <a href="/privmsg?folder=inbox">
                        <span>Messages <b id='boldStuff'>(none)</b></span>
                                                    <script type="text/javascript">
                                                    function changeText(){
                                                            
                                                         var messageString = document.getElementById('i_icon_mini_new_message').getAttribute('alt');
                     var messageArray = messageString.split(" ");
                                                      var messageNumber = (messageArray[2] != "") ? messageArray[2] : "0";
                                                      if (messageArray[2] != "") {
                                                      document.getElementById('mainAcc').innerHTML = " (!)";
                                                      }
                                                         document.getElementById('boldStuff').innerHTML = " (" + messageNumber + ")";
                                            
                                                    }
                                                      changeText();
                                                    </script>
                                                       
                     </a>
                  </li>
Thanks for pointing me in the right direction!
avatar
ian2000
Forumember

Posts : 42
Reputation : 3
Language : English

https://forum.somiibo.com

Back to top Go down

Solved Re: Code for number of unread PMs

Post by SLGray April 13th 2015, 3:20 am

Thanks for posting the solution.

Topic solved and archived


Code for number of unread PMs Slgray10

When your topic has been solved, ensure you mark the topic solved.
Never post your email in public.
SLGray
SLGray
Administrator
Administrator

Male Posts : 51581
Reputation : 3526
Language : English
Location : United States

https://forumsclub.com/gc/128-link-directory/

Back to top Go down

Back to top

- Similar topics

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