Developer forum

Forum » CMS - Standard features » Edit Comments in frontend?

Edit Comments in frontend?

Aki Ruuskanen
Aki Ruuskanen
Reply

Hi,

Is it possible to edit product comments in frontend. I cannot fins any documentation about it. 

Tried with "Edit" and "Update" in "Commad.Command" field. 

Regards / Aki


Replies

 
Nicolai Pedersen Dynamicweb Employee
Nicolai Pedersen
Reply
This post has been marked as an answer

You cannot - it has 3 commands:

  1. 'create'
  2. 'delete' (requires token)
  3. 'activate' (requires token)

2+3 requires that you send ?Comment.ID={commentId}&Comment.Token={Token}

What you can do is 'cheating' and create an edit form for a comment and then when submitted, send 2 requests (using JS) - one for deleting the old comment and one for creating the new one. This works - and triggers approval workflow to run again if that is setup. Only thing here is that the timestamp will change if not handled in Notifications.Commenting.OnBeforeComment notification subscriber.

Another approach would be to send the 'create' command with an additional hidden field (I.e. "Edit.Comment.ID") that includes the comment being edited. Then again using the Notifications.Commenting.OnBeforeComment subscriber, find the comment being edited from the "Edit.Comment.ID" field, get its date, update the date on the new comment (passed to the notification arguments) and then delete the comment found with the "Edit.Comment.ID"

Of course ensure to take security into consideration.

BR Nicolai

Votes for this answer: 1
 
Aki Ruuskanen
Aki Ruuskanen
Reply

Thanks for the suggestions. Went with the subscriber approach. 

Regards / Aki

 

You must be logged in to post in the forum