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

Consu Aug 04, 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

0 votes
Answer accepted
Consu Aug 05, 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>
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

0 votes
Wayne Wong Atlassian Team Aug 04, 2014 • edited Apr 04, 2018

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 Aug 05, 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 Aug 05, 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 Feb 08, 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 Dec 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 Dec 23, 2018

@Jazon Reyes unfortunately I did not find a way. 

0 votes
George Lewe (LSY) Nov 02, 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
George Lewe (LSY) Nov 06, 2015

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 in Next-gen

Introducing subtasks for breaking down work in next-gen projects

Teams break work down in order to help simplify complex tasks. This is often done iteratively, with tasks being broken down into smaller tasks and so on until the work is accurately captured in well-...

10,654 views 49 52
Read article

Community Events

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

Find an event

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

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you