This tutorial lets you add 2 buttons that allow you to move to another private message without going back to the inbox.
Overview
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])); } } });
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>
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.
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.
|