Bizarre request I know, but, I've been asked if it is possible to reverse the order of comments, ie.e. have the most recent at the top?
You can do that client-side with a quick JavaScript hack...
Browse to Confluence Admin | Look & Feel | Custom HTML
Add this to At the end of the HEAD:
<script> AJS.toInit(function () { $comments = AJS.$('#page-comments'); $comments.children().each(function (i,li) {
$comments.prepend(li);
}); }); </script>
Check the related blogpost for more tips :)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
No problem. If it worked, please mark it as correct :-)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Also, if you want to allow the sort order to be changed, update the JavaScript to something like...
function reverseCommentOrder () { var $comments = AJS.$('#page-comments'); $comments.children().each(function(i,li){$comments.prepend(li)}); } AJS.toInit(function ($) { reverseCommentOrder(); $('#comments-section-title').append(
'<a id="page-comments-reverse" href="#">(Reverse Order)</a>'
); $('#page-comments-reverse')
.css({ 'color':'#999','font-size':'0.65em'})
.click(function (e) { reverseCommentOrder(); e.preventDefault(); }); });
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
This doesn't change the ordering in any nested comments -- I'm not really sure what the correct behaviour would be there. Thoughts?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Actually it sorta makes sense this way, the top level comments are presented in revese order and the replies are nested in reply order under the original - this seems pretty clear to me, I don't think I'd want the replies reversed as well.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
As I suspected. I couldn't really figure out what else would work.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
This works great for the first comment, but what about the subcomments underneath if people reply?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
How can I get to the area Confluence Admin | Look & Feel | Custom HTML???
Thanks in advance
Sibel
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Click on the admin cog, then look for look and feel, and custom html in the admin menu.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
For the sort order, anyway I can do that for only 1 space?
Thanks,
V
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Sure, try this:
<script>
var mySpaceKey = 'EXAMPLE'; // Change this to the space key for the 1 space
AJS.toInit(function(){
if (AJS.params.spaceKey == mySpaceKey) { $comments = AJS.$('#page-comments'); $comments.children().each(function(i,li){$comments.prepend(li)});
} }); </script>
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Indeed, the above solution only sorts the top level comments, not the sub comments. The reason is that only the top comment container has an identifier ("page-comments"). Such a global identifier can only be assigned to something that is always present. That is not the case for the sub-comments. So the sub-comments IDs are created on the fly and a solution like the above cannot know them beforehand of course.
Also, inserting the toggle link into the comment block has the flaw that it is removed when Confluence re-creates it after a new comment is added. Only a page refresh will make it appear again.
Other than that it works. Here is a solution how you can do this with a user macro so you can apply it to certain pages only by adding it onto the page.
## Macro title: Reverse Comments ## Macro body processing: No macro body ## ## Created by: George Lewe ## Created on: 2015-11-06 ## ## This macro toggles page comments sort order ## ## @noparams <script> function rev(i, el) { $comments = AJS.$('#page-comments'); $comments.prepend(el) } function reverseCommentOrder() { if (AJS.$('meta[name=ajs-form-name]').attr("content") != "editcommentform"){ $comments = AJS.$('#page-comments'); $comments.children().each(rev) } } AJS.toInit(function() { if($("#page-comments-reverse").length == 0) { AJS.$('#comments-section-title').append('<a id="page-comments-reverse" href="#" onclick="reverseCommentOrder();" style="color: #999; font-size: 0.65em;">[Toggle order...]</a>;'); } }); </script>
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
where do would I insert this in a Space?
I am using 5.7.1.
Thanks!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
The solution above is a page macro. It only applies to the page when you insert it. It is not space-wide.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I have placed the above code in the template of my user macro but when I save the page where the macro is it spits out the code and thus not ordering the comments?
How can I make the code be executed and not spit on the page?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi all,
I noticed that the editor here replace < with <, and > with > in the code I provided. I edited the code section accordingly.
We still use that macro successfully. The user macro is set to "No macro body".
Best regards,
George
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
If you want to do this per space simply wrap it in {html} tags and place it in the custom header area: Space Admin -> Look And Feel -> Themes -> Configure Theme -> Header.
{html} <script> AJS.toInit(function(){ $comments = AJS.$('#page-comments'); $comments.children().each(function(i,li){$comments.prepend(li)}) }); </script> {html}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
This solution will handle new comments and replies to those comments
<script> AJS.toInit(function(){ if (AJS.$('meta[name=ajs-form-name]').attr("content") != "editcommentform" && AJS.$('meta[name=ajs-form-name]').attr("content") != "threadedcommentform"){ // Only reverse comments if you're not editing one of them $comments = AJS.$('#page-comments'); $comments.children().each(function(i,li){$comments.prepend(li)}); } }); </script>
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Is this still viable for v 6.15.9 and above?
The Custom HTML inserted via the Admin console - does not seem to be working, but per space it does!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Try now. I've just updated my old answers from 2012 - when Atlassian migrated the content from the old community (answers.atlassian.com), some html was mistakenly escaped.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks David!
Really appreciate that!
Is that the same for the one with the choice of sort order? add <script> tags?
V
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I'm not sure if this thread is still alive. I tried all the codes above, they all work. The thing is, everytime i enter a new comment, it is still displayed at the bottom. Any possible way that the newly entered comment(without refreshing the page) can appear on top as well?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Can I do that at just the Space Level, not a a global change?
Using v 5.7.1 Space Admin -> Look And Feel -> Themes -> Configure Theme -> Header does not exist. I get the option of current theme or choose new theme and confirm.
I notice there is a Blog Layout in the Space Tool->Look and Feel->Blog Post Layout
Guess I can just put that in there?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Is it possible to reverse the comments order in the On Demand version of Confluence? We have 145 comments On one of our meeting notes page that grows daily… Scrolling to the bottom is becoming a bit of a pain. Thanks, Robert
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Robert,
Any update on this issue . Please let us know, we are also searching for the same
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
No, Karthik.
We have found no solution for reversing the sort order in the On Demand/cloud version of confluence. This is just one of the many limitations that we found since moving to the cloud instance. Seems like it should be a relatively minor thing to fix. Apparently, it's not high on the Atlassian scorecard.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Robert,
But we need to get by adding java script on header side, I think It is also not work out. We are finding any changes. Please suggest if you have any alternate method.
Thanks
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
There is no way to do it on Cloud. AS you say, you need to change or add some javascript. Which you can't do on Cloud.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
This works great for the first comment, but what about the subcomments underneath if people reply?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
This still has issues when you try and reply to a comment. Can anyone help?
Is there an issue to have Atlassian make this part of the code functionality?
Thanks
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I am having the same issue with the Documentation theme in Confluence 4.1.9. I cannot edit comments. It brings up the editor, does not show the existing comment an does not give you a cursor. The preview button does not work either.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi, I am using confluence V3.5 .
I tried to use David's solution which worked great but now it seems that
I am unable to reply on an existing comment using rich text editor, only by wiki markup (test on Chrome).
did someone else had this issue? is there a solution for this?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I've not tried this in Confluence 3.5 only 4.x. Sorry.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Try this to fix the comment edit/reply problem...
<script> AJS.toInit(function ($) { if ($('meta[name=ajs-form-name]').attr("content") != "editcommentform"){ // Only reverse comments if you're not editing one of them $comments = $('#page-comments'); $comments.children()
.each(function (i, li) {
$comments.prepend(li);
}); } }); </script>
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
This is excellent David. Seems to work.
So the complete script is:
<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>
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Has anyone attempted something similar with Questions? A reverse sort or a way of maintaining Question order is what I'm looking for.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Is there a way to just add the reverse link without changing the default order?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.