Show comments in the reverse order on Confluence 5

Consu August 4, 2014

Hello,

I found an old question on the same topic (https://answers.atlassian.com/questions/28999/is-it-possible-to-reverse-the-order-in-which-comments-appear) but the solution that was proposed there was for 3.5 and I don't seems to manage o have it work to work on Confluece 5.

Can someone suggest a way to make comments showing in the reverse order on the latest version?

Thanks for the help

5 answers

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

0 votes
Answer accepted
Consu August 5, 2014

The answer is as given on the related question https://answers.atlassian.com/questions/28999/is-it-possible-to-reverse-the-order-in-which-comments-appear<br< a="">>

It works perfectly with :

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
<script>
function reverseCommentOrder(){
if (AJS.$('meta[name=ajs-form-name]').attr("content") != "editcommentform"){
// Only reverse comments if you're not editing one of them
$comments = AJS.$('#page-comments');
$comments.children().each(function(i,li){$comments.prepend(li)});
}
}
AJS.toInit(function(){
reverseCommentOrder();
AJS.$('#comments-section-title').append('<a id="page-comments-reverse" href="#">(Reverse Order)</a>');
AJS.$('#page-comments-reverse').css({ 'color':'#999','font-size':'0.65em'}).click(function(e){
reverseCommentOrder();
e.preventDefault();
});
});
</script>
1 vote
George Lewe (LSY)
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
November 6, 2015

I figured out a way to add this feature as a user macro. See this related post:

https://answers.atlassian.com/questions/28999

0 votes
George Lewe (LSY)
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
November 2, 2015

Hi all,

thanks for the nice script. We do not have HTML enabled, however, a user macro can also be used and inserted in the Navigation box of the Dcoumentation Theme. At least you have toggle sorting per space then.

I wrote the user macro with the above code but it throws an error "Error occurred rendering template content". I nailed it down to this line:

$comments.children().each(function(i,li){$comments.prepend(li)});

Everything else goes through, but the above line causes the macro to fail rendering. Any idea on how to make it work?

Best regards,
George

0 votes
waynewong
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
August 4, 2014

HI there,

 

Can I know is your confluence freshly installed?

When you put the suggested customization in your confluence, is that any specific error shows ?

Could you please check if your HTML macro enabled? It's disbaled by default for conflence 5.

https://confluence.atlassian.com/display/DOC/Enabling+the+html-include+Macro

 

Thank you.


Regards,


Wayne Wong

 

Consu August 5, 2014

Hello Wayne,

no it is not freshly installed, it runs since a few months.

I don't have a specific error, just the comments are not showing in the reverse order...

Html macro is active.

There are quiet a lot of "solutions" on the linked Answer. I gather that the "right" one should be

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
<script>
function reverseCommentOrder(){
if (AJS.$('meta[name=ajs-form-name]').attr("content") != "editcommentform"){
// Only reverse comments if you're not editing one of them
$comments = AJS.$('#page-comments');
$comments.children().each(function(i,li){$comments.prepend(li)});
}
}
AJS.toInit(function(){
reverseCommentOrder();
AJS.$('#comments-section-title').append('<a id="page-comments-reverse" href="#">(Reverse Order)</a>');
AJS.$('#page-comments-reverse').css({ 'color':'#999','font-size':'0.65em'}).click(function(e){
reverseCommentOrder();
e.preventDefault();
});
});
</script>
Am I right?

Consu August 5, 2014

Hold on, sorry. A lot of noise for nothing! I manage to get it to work now. It was just me being silly! Sorry for this and thanks for the help!

Ian February 8, 2018

I have tested the above js code and it is working however there are some issues:

When the comments have been reverse ordered and you right another comment,the new comment which essentially should be at the top is at the bottom and you have to reload the page so that it is displayed up. @Consu did you experience the same?

Jazon Reyes December 23, 2018

hi @Ian I'm having the same issue. May I know if you have already found out the way to get the new comments to be displayed on top without refreshing the page too?

Ian December 23, 2018

@Jazon Reyes unfortunately I did not find a way. 

0 votes
waynewong
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
August 4, 2014

HI there,

Can I know is your confluence fresh installed?

When you put the suggested customization in your confluence, is that any specific error shows ?

Could you please check if your HTML macro enabled? It's disbaled by default for conflence 5.

https://confluence.atlassian.com/display/DOC/Enabling+the+html-include+Macro

Thank you.


Regards,


Wayne Wong

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

TAGS
AUG Leaders

Atlassian Community Events