This server will be upgraded at 3pm Sydney time on December 3rd (December 2nd, 8pm PST) and will be down for up to 30 minutes.
This documentation relates to an early version of Confluence.
View this page in the current documentation or visit the current documentation home.

Updating a theme for editable comments

All Versions
Click for all versions
Confluence 2.0 to 2.5 Documentation

Index

This is a simple how-to that shows the steps to upgrade your plugin for editable comments.

Modify sharedcomments.vmd

Making your themes compatible with editable comment only requires modifying sharedcomments.vmd. There are 3 parts to update. A good example of this is the Clickr Theme.

Adding the edit link

First to enable editable comment you will need to give access to the edit function.
Adding the link is as simple as adding the following piece of code near your existing 'Permalink' and 'Remove Comment' links:

#if ($permissionHelper.canEdit($remoteUser, $comment ))
  | <a id="edit-$comment.id" href="$req.contextPath$generalUtil.customGetPageUrl($page)showComments=true&amp;editComment=true&amp;focusedCommentId=$comment.id#comment-$comment.id">$action.getText('edit.name')</a>
#end
Enable inline editing

Editing a comment happens inline. Therefore the editor must be added when rendering the comment being edited as follow:

#if ($focusedCommentId == $comment.id && $action.editComment && $permissionHelper.canEdit($remoteUser, $comment))
  <form name="editcommentform" method="POST" action="$req.contextPath/pages/doeditcomment.action?pageId=$page.id&amp;commentId=$comment.id">
    #bodytag (Component "name='content'" "theme='notable'" "template='wiki-textarea.vm'")
      #param ("formname" "editcommentform")
      #param ("spaceKey" "$generalUtil.urlEncode($spaceKey)")
      #param ("rows" 15)
      #param ("cols" 70)
      #param ("width" "100%")
      #param ("tabindex" "4")
      #param ("tdcolor" "f0f0f0")
      #param ("toolbarExpanded" "false")
      #param ("initialFocus" "false")
      #param ("edit" "true")
      #param ("heartbeat" "false")
      #param ("wikiContent" "$comment.content")
      #param ("wysiwygContent" "$action.helper.wikiStyleRenderer.convertWikiToXHtml($comment.toPageContext(), $comment.content)")
    #end
    #commentSubmission()
  </form>
#else
  ## your current comment rendering...
#end
Add update information

This step is optional but it always nice for user to knwo when a comment has been updated and by who. The following piece of code gets the necessary information.

#if ( $action.helper.shouldRenderCommentAsUpdated($comment) )
  #if ( $comment.creatorName == $comment.lastModifierName )
    $action.getText("comment.updated.by.author", ["#usernameLink ($comment.lastModifierName)", $action.dateFormatter.formatDateTime( $comment.lastModificationDate )])
  #else
    $action.getText("comment.updated.by.non.author", ["#usernameLink ($comment.lastModifierName)", $action.dateFormatter.formatDateTime( $comment.lastModificationDate )])
  #end
#end

The shouldRenderCommentAsUpdated method is a convenience method that checks whether the comment has been updated by its creator more than 10 minutes after being created. It exists so that comments will not get cluttered with useless information because of a quick fix made shortly after the comment is posted. One can adjust the time frame by passing a number of seconds as the second argument to this method.

Finally, if the updater of the comment is different to the original author of the comment, his name is displayed.

Labels

editable editable Delete
comments comments Delete
confluence24 confluence24 Delete
theme theme Delete
Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.