inherit
256720
0
Jun 18, 2020 15:10:59 GMT -8
bluecargo1
36
October 2018
bluecargo1
|
Post by bluecargo1 on Oct 31, 2018 19:41:20 GMT -8
Hey, I have seen multiple help threads involving how to reorder posts in the Post Summary, but for some reason not for the Post List. I was wondering if anyone could develop a code for me to do this. I need it to make the recent post on top, so basically just reversing the post order. I understand posts can only be reordered in the page that its in, since code can't access the logs in other pages. What I need is code that will reorder the posts in the page in pagination that you click on, so every time you click on another page in pagination it reverses the posts in that page. I hope I clarified enough, please ask me if you need some more detail. To some it up: I need code that will reverse the posts every time you visit a page on pagination so the recent one is on top. Thanks!
|
|
inherit
249312
0
Nov 2, 2018 14:34:00 GMT -8
bartlesby
110
September 2017
bartlesby
|
Post by bartlesby on Oct 31, 2018 20:30:28 GMT -8
Hey, I have seen multiple help threads involving how to reorder posts in the Post Summary, but for some reason not for the Post List. I was wondering if anyone could develop a code for me to do this. I need it to make the recent post on top, so basically just reversing the post order. I understand posts can only be reordered in the page that its in, since code can't access the logs in other pages. What I need is code that will reorder the posts in the page in pagination that you click on, so every time you click on another page in pagination it reverses the posts in that page. I hope I clarified enough, please ask me if you need some more detail. To some it up: I need code that will reverse the posts every time you visit a page on pagination so the recent one is on top. Thanks! I'd try something simple like: <script> function flip() { var x = $("tr[id^='post-']"); var y = $.makeArray(x); var z = x.parent(); x.remove(); z.append(y.reverse()); } $(function() { if (pb.data("route").name == "thread") { flip(); pb.events.on("pageChange", flip); } }); </script> It just turns the list of posts into an array, removes the original, and appends the reversed array to the original's parent object, replacing the original with the inverse. Using the proboards event, you can trigger that every time pagination happens. Totally functional-- you can stick it into any header or footer you want.
|
|
inherit
256720
0
Jun 18, 2020 15:10:59 GMT -8
bluecargo1
36
October 2018
bluecargo1
|
Post by bluecargo1 on Nov 1, 2018 16:36:08 GMT -8
Hey, I have seen multiple help threads involving how to reorder posts in the Post Summary, but for some reason not for the Post List. I was wondering if anyone could develop a code for me to do this. I need it to make the recent post on top, so basically just reversing the post order. I understand posts can only be reordered in the page that its in, since code can't access the logs in other pages. What I need is code that will reorder the posts in the page in pagination that you click on, so every time you click on another page in pagination it reverses the posts in that page. I hope I clarified enough, please ask me if you need some more detail. To some it up: I need code that will reverse the posts every time you visit a page on pagination so the recent one is on top. Thanks! I'd try something simple like: <script> function flip() { var x = $("tr[id^='post-']"); var y = $.makeArray(x); var z = x.parent(); x.remove(); z.append(y.reverse()); } $(function() { if (pb.data("route").name == "thread") { flip(); pb.events.on("pageChange", flip); } }); </script> It just turns the list of posts into an array, removes the original, and appends the reversed array to the original's parent object, replacing the original with the inverse. Using the proboards event, you can trigger that every time pagination happens. Totally functional-- you can stick it into any header or footer you want. Worked perfectly, thank for the help!
|
|
inherit
256720
0
Jun 18, 2020 15:10:59 GMT -8
bluecargo1
36
October 2018
bluecargo1
|
Post by bluecargo1 on Nov 3, 2018 10:06:42 GMT -8
Hey, I have seen multiple help threads involving how to reorder posts in the Post Summary, but for some reason not for the Post List. I was wondering if anyone could develop a code for me to do this. I need it to make the recent post on top, so basically just reversing the post order. I understand posts can only be reordered in the page that its in, since code can't access the logs in other pages. What I need is code that will reorder the posts in the page in pagination that you click on, so every time you click on another page in pagination it reverses the posts in that page. I hope I clarified enough, please ask me if you need some more detail. To some it up: I need code that will reverse the posts every time you visit a page on pagination so the recent one is on top. Thanks! I'd try something simple like: <script> function flip() { var x = $("tr[id^='post-']"); var y = $.makeArray(x); var z = x.parent(); x.remove(); z.append(y.reverse()); } $(function() { if (pb.data("route").name == "thread") { flip(); pb.events.on("pageChange", flip); } }); </script> It just turns the list of posts into an array, removes the original, and appends the reversed array to the original's parent object, replacing the original with the inverse. Using the proboards event, you can trigger that every time pagination happens. Totally functional-- you can stick it into any header or footer you want. Actually, bartlesby , I realized something stopped working using this code. I testing the logs, when I found that the selection options ($[post.select_options]) wasn't doing anything when I clicked. It usually shows the moderator options, if you want to delete the post etc, but nothing happened when I clicked on it. I know for sure the reason is due to the code, since after deleting the code it was working again, and after adding it back it stopped. Do you know why?
|
|
inherit
249312
0
Nov 2, 2018 14:34:00 GMT -8
bartlesby
110
September 2017
bartlesby
|
Post by bartlesby on Nov 3, 2018 14:01:16 GMT -8
bluecargo1Oops, my mistake. Try this instead: <script> function flip() { var x = $("tr[id^='post-']"); var xlen = x.length; var z = x.parent(); while (xlen--) { z.append(x[xlen]); } }
$(function() { if (pb.data("route").name == "thread") { flip(); pb.events.on("pageChange", flip); } }); </script> That should preserve those elements.
|
|
inherit
256720
0
Jun 18, 2020 15:10:59 GMT -8
bluecargo1
36
October 2018
bluecargo1
|
Post by bluecargo1 on Nov 4, 2018 20:10:08 GMT -8
bluecargo1 Oops, my mistake. Try this instead: <script> function flip() { var x = $("tr[id^='post-']"); var xlen = x.length; var z = x.parent(); while (xlen--) { z.append(x[xlen]); } }
$(function() { if (pb.data("route").name == "thread") { flip(); pb.events.on("pageChange", flip); } }); </script> That should preserve those elements. bartlesby Yes, the options come back up again! The only problem is that once the post is deleted, the order goes back to normal, and I have to refresh the page / change back forward and back to get it reordered again. Is there possibly another proboard event upon post deletion, so you can run flip() on that, instead of manually refreshing every time?
|
|
inherit
249312
0
Nov 2, 2018 14:34:00 GMT -8
bartlesby
110
September 2017
bartlesby
|
Post by bartlesby on Nov 5, 2018 8:17:19 GMT -8
bartlesby Yes, the options come back up again! The only problem is that once the post is deleted, the order goes back to normal, and I have to refresh the page / change back forward and back to get it reordered again. Is there possibly another proboard event upon post deletion, so you can run flip() on that, instead of manually refreshing every time? I believe changing the event to afterSearch should do the trick: $(function() { if (pb.data("route").name == "thread") { flip(); pb.events.on("afterSearch", flip); } }); That should trigger on pagination and when the page is changed after deleting a post. Let me know if there are any other issues.
|
|
inherit
256720
0
Jun 18, 2020 15:10:59 GMT -8
bluecargo1
36
October 2018
bluecargo1
|
Post by bluecargo1 on Nov 5, 2018 9:10:13 GMT -8
bartlesby Yes, the options come back up again! The only problem is that once the post is deleted, the order goes back to normal, and I have to refresh the page / change back forward and back to get it reordered again. Is there possibly another proboard event upon post deletion, so you can run flip() on that, instead of manually refreshing every time? I believe changing the event to afterSearch should do the trick: $(function() { if (pb.data("route").name == "thread") { flip(); pb.events.on("afterSearch", flip); } }); That should trigger on pagination and when the page is changed after deleting a post. Let me know if there are any other issues. Yes that works great!! Thanks for all this help, I'll let you know if something goes wrong
|
|