Automerge Double Posts

Go down

Automerge Double Posts Empty Automerge Double Posts

Post by Wecoc on June 11th 2020, 3:02 pm

This is a feature I've been using in my forum: When a user makes multiple posts in a row they are displayed as part of the same post, with a thin line that seperates their content. The merge is applied on the post box, and the profile and signature are displayed only once, but the quote/edit/etc buttons, the post title and date, the reputation/like system and the edit text are still displayed in each one separately, for obvious reasons.

Example:
Automerge Double Posts Multipost-test

It's not just double posts, if there are 15 posts in a row it will be applied on all them in the same manner (and you should probably ban that user, lol).

I've tested it only on phpBB3 but it's pretty basic and should work in others as well, maybe with a few edits... I'll appreciate feedback on that Smile

1. Javascript


Add this on the Javascript list, with position option "In topics".

Code:
/*
* -- Automerge Double Posts --
* Version: 1.0 EN (2020-06-11) [phpBB3]
* Author: Wecoc
* Description: When a user makes multiple posts in a row, they are displayed as part of the same post,
* with a thin line that seperates their content.
*/

$(function() {
  var posts = $(".post");
  if (posts.length < 2) return;
  for(var i=0; i<posts.length; i++ ) {
    var post = posts[i], author = post.querySelector(".author a");
    if (author == null) break;
    author = author.innerText;
    if (i > 0) {
      var prev_post = posts[i-1], prev_author = prev_post.querySelector(".author a");
      if (prev_author == null) break;
      prev_author = prev_author.innerText;
      if (author == prev_author) {
        $(post).addClass("has_prev");
      }
    }
    if (i < (posts.length - 1)) {
      var next_post = posts[i+1], next_author = next_post.querySelector(".author a");
      if (next_author == null) break;
      next_author = next_author.innerText;
      if (author == next_author) {
        $(post).addClass("has_next");
        post.appendChild(next_post);
      }
    }
  }
});

2. CSS


Code:
/* Hide the signature on multiposts */
.post.has_next > .inner > .postbody > .signature_div { display: none; }

/* Hide the profile on multiposts */
.post.has_next .post .postprofile { display: none; }

/* Hide the scroll buttons on multiposts */
.post.has_next > .inner > div.clear, .post.has_next > .inner > p.right { display: none; }

/* Change the basic format of the multiposts and add a border line to separate them */
.post.has_next .post {
  border: none;
  box-shadow: none;
  float: left;
  margin-top: 10px;
  padding-top: 10px;
  width: 100%;
  border-top: 2px solid #313131 !important;
  border-radius: 0 !important;
}
Wecoc
Wecoc
Forumember

Male Posts : 139
Reputation : 106
Language : Catalan, Spanish, English

View user profile

Back to top Go down

Automerge Double Posts Empty Re: Automerge Double Posts

Post by Neptune- on June 11th 2020, 3:52 pm

Hello,


We have a similar tutorial on French Support Forum.

If it can help, works for phpBB2 too

Translated in Automerge Double Posts Flag-es -> phpbb: Agregada doble publicación

And in Automerge Double Posts Flag-gb -> phpbb: Aggregate double post
Neptune-
Neptune-
Forumember

Male Posts : 394
Reputation : 83
Language : French (10), English (8), CSS (5), HTML (4), Javascript (4)
Location : France

View user profile https://www.galaxie-series.net/

Back to top Go down

Automerge Double Posts Empty Re: Automerge Double Posts

Post by YoshiGM on June 11th 2020, 5:56 pm

Neptune is right.. We already have a tutorial created by Ea/Etana written some years ago Wink
But, thanks for the tip cheers
YoshiGM
YoshiGM
Forumember

Male Posts : 919
Reputation : 120
Language : Spanish & English
Location : Mexico

View user profile http://asistencia.foroactivo.com/u21373

Back to top Go down

Back to top


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