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.
The forum of the forums
3 posters

    Code for number of unread PMs

    avatar
    ian2000
    Forumember


    Posts : 42
    Reputation : 3
    Language : English

    Solved Code for number of unread PMs

    Post by ian2000 Mon 13 Apr - 2:08

    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 Mon 13 Apr - 4:16; edited 1 time in total
    Ange Tuteur
    Ange Tuteur
    Forumaster


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

    Solved Re: Code for number of unread PMs

    Post by Ange Tuteur Mon 13 Apr - 2:49

    Hey,

    Did you delete {GENERATED_NAV_BAR} from the overall_header template ?
    avatar
    ian2000
    Forumember


    Posts : 42
    Reputation : 3
    Language : English

    Solved Re: Code for number of unread PMs

    Post by ian2000 Mon 13 Apr - 3:01

    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:
    Ange Tuteur
    Ange Tuteur
    Forumaster


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

    Solved Re: Code for number of unread PMs

    Post by Ange Tuteur Mon 13 Apr - 3:04

    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>
    avatar
    ian2000
    Forumember


    Posts : 42
    Reputation : 3
    Language : English

    Solved Re: Code for number of unread PMs

    Post by ian2000 Mon 13 Apr - 3:21

    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

    Solved Re: Code for number of unread PMs

    Post by ian2000 Mon 13 Apr - 4:16

    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!
    SLGray
    SLGray
    Administrator
    Administrator


    Male Posts : 51554
    Reputation : 3524
    Language : English
    Location : United States

    Solved Re: Code for number of unread PMs

    Post by SLGray Mon 13 Apr - 4:20

    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.

      Current date/time is Wed 13 Nov - 17:58