Next and previous buttons for private messages Hitskin_logo Hitskin.com

This is a Hitskin.com skin preview
Install the skinReturn to the skin page

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.
2 posters

    Next and previous buttons for private messages

    Ange Tuteur
    Ange Tuteur
    Forumaster


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

    Tutorial Next and previous buttons for private messages

    Post by Ange Tuteur July 3rd 2015, 12:32 pm

    Next and previous buttons for private messages


    This tutorial lets you add 2 buttons that allow you to move to another private message without going back to the inbox. Smile

    Next and previous buttons for private messages 09615110 Overview


    Next and previous buttons for private messages Captur35


    Next and previous buttons for private messages 09615110 The JavaScript


    Go to Administration Panel > Modules > JavaScript codes management and create a new script.

    Title : Your choice
    Placement : In all the pages
    Paste the following code and submit :
    Code:
            $(function(){
                "use strict";
                var a=["inbox","savebox"],b,dl=document.location.search;
                for(b in a){
                    if(dl.indexOf("folder="+a[b]+"&mode=read&p=")!=-1){
                        (function(box){
                            $.get("/privmsg?folder="+box,function(mpStart){
                                var messages=$("a[href^='/privmsg?folder="+box+"&mode=read&p=']",mpStart).toArray();
                                var linkToObject=function(lc){return {"href":lc.href,"title":lc.title,"text":lc.textContent}};
                                var setButtons=function(){
                                    var getPid=function(a){return /p=(\d+)/.exec(a)[1]},message;
                                    for(i=0;i<messages.length;i++){
                                        message=messages[i];
                                        if(getPid(dl)==getPid(message.href)){
                                            if(i||i<messages.length-1){
                                                var $navMP=$("<div>",{id:"navMP"});
                                                if(i<messages.length-1)$navMP.append($('<a>',{"id":"navMP-precedent","href":messages[i+1].href,"title":messages[i+1].title||messages[i+1].text}));
                                                if(i)$navMP.append($('<a>',{"id":"navMP-suivant","href":messages[i-1].href,"title":messages[i-1].title||messages[i-1].text}));
                                                $("#navMP").length?$("#navMP").html($navMP.html()):$("form[action^='/privmsg']").before($navMP);
                                            }
                                            break;
                                        }
                                    }
                                };
                                var requests=$("a[href^='/privmsg?folder="+box+"&start=']",mpStart).slice(0,-1).toArray();
                                if(requests.length){
                                    requests=requests.map(function(e){return $.get(e.href)});
                                    $.when.apply(null,requests).done(function(){
                                        var d_msg,requestData;
                                        if(requests.length>1){
                                            for(i=0;i<arguments.length;i++){
                                                requestData=arguments[i][0];
                                                d_msg=$("a[href^='/privmsg?folder="+box+"&mode=read&p=']",requestData).toArray();
                                                messages=messages.concat(d_msg);
                                            }
                                            messages.map(linkToObject);
                                            setButtons();
                                        }else{
                                            requestData=arguments[0];
                                            d_msg=$("a[href^='/privmsg?folder="+box+"&mode=read&p=']",requestData).toArray();
                                            messages=messages.concat(d_msg).map(linkToObject);
                                            setButtons();
                                        }
                                    });
                                }else{
                                    messages=messages.map(linkToObject);
                                    setButtons();
                                }
                            });
                        }(a[b]));
                    }
                }
            });


    Next and previous buttons for private messages 997260 The JavaScript code is designed to be compatible with all forum versions ( phpbb2, phpbb3, punbb, invision ). If you want to decide for yourself where to place the next and previous buttons, you can simply edit your privmsgs_read_body template and add the following code wherever you want :
    Code:
    <div id="navMP"></div>

    Next and previous buttons for private messages 997260 The display of the buttons may take more or less time depending on your connection speed and configuration of the number of topics per page on your forum. The greater the number of topics per page, the less requests the script will send, as it will be slower.

    You can check the total number of topics per page here :
    Administration Panel > General > Messages and Emails > Configuration, find the option topics per page.


    Next and previous buttons for private messages 09615110 The CSS


    Go to Administration Panel > Display > Colors > CSS stylesheet, and add the following code to your stylesheet :
    Code:
    #navMP>a{
      display:inline-block;
      padding-left:10px;
      padding-right:10px;
      font-size:16px;
      line-height:16px;
      color:#eee;
      background:#BDC8D0;
      text-decoration:none !important;
      border:1px solid #aaa;
    }
    #navMP>a:hover{
      color:#fff;
      background:#CDD8E0;
      text-decoration:none !important;
    }
    #navMP-precedent{
      border-radius:8px 0 0 8px;
    }
    #navMP-suivant{
      float:right;
      border-radius:0 8px 8px 0;
    }
     
    #navMP-precedent::before{
      content:"Previous"
    }
    #navMP-suivant::before{
      content:"Next"
    }

    You can of course modify this code to your liking.

    faerycharmjulie likes this post

    SLGray
    SLGray
    Administrator
    Administrator


    Male Posts : 51507
    Reputation : 3519
    Language : English
    Location : United States

    Tutorial Re: Next and previous buttons for private messages

    Post by SLGray July 28th 2017, 6:47 pm

    The JavaScript has been updated.



    Next and previous buttons for private messages Slgray10

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