It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Show comments in the reverse order on Confluence 5

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

0 votes
Answer accepted

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>
0 votes
Wayne Wong Atlassian Team Aug 04, 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

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

 

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?

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!

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?

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 I'm New Here Dec 23, 2018

@Jazon Reyes unfortunately I did not find a way. 

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

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

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

Suggest an answer

Log in or Sign up to answer
This widget could not be displayed.
This widget could not be displayed.
Community showcase
Published Thursday in Confluence

Confluence CVEs and common questions

Two vulnerabilities have been published for Confluence Server and Data Center recently: March 20, 2019 CVE-2019-3395 / CVE-2019-3396 April 17, 2019 CVE-2019-3398 The goal of this article is...

116 views 0 10
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you