Be Good Not Bad : Web Design :: Brian Warren : Denver, Colorado

Admin Comments: Expression Engine Plugin

Admin Comments is a plugin that lets the superuser delete or close any comment. Additionally, users who are logged in members can delete their own comments.

Here’s how you use it:

The Links

The first thing you want to do is create the links. Make sure these are inside the {exp:comment:entries} tags. I usually put them near the comment meta information (date, time, author link, etc).

Delete Link Parameters

commentid (Required) – The comment_id of the comment you wish to display a delete link for. (E.g. 47) Usually you can grab this via the {comment_id} tag
template (Required) – The name of the template containing the {exp:admin_comment:delete} plugin code. (E.g. site/delete)
authorid (Required) – The author_id of the comment in question. Usually you can grab this via the {author_id} tag. It’s always a number.
showconfirm (Optional) – If this is set to “true” then the javascript “are you sure?” confirmation box will appear. Defaults to false. Danger!

Example usage inside a comment entries tag:

{exp:admin_comment:delete_link 
  commentid="{comment_id}" 
  showconfirm="false" 
  authorid="{author_id}" 
  template="embeds/delete-comment"}
    Delete
{/exp:admin_comment:delete_link}
Close Link

The exact same parameters and behavior applies to the close link as did with the delete link tags.

{exp:admin_comment:close_link 
  commentid="{comment_id}" 
  authorid="{author_id}" 
  template="embeds/close-comment"}
    Close
{/exp:admin_comment:close_link}
Close & Delete Templates

The next thing you need to do is create templates that house the actual act of deleting and closing the comments. This is quite simple.

  1. Create a template for deleting comments. This is the same template to which you’re referring in the template parameter in the exp:admin_comment:delete_link tag.
  2. Inside this template put the following tag: {exp:admin_comment:delete returnlink="true"}

Note: The parameter “returnlink“ is optional and defaults to false. If this is set to “true” then a link to the previous page will appear following a successful comment deletion. The text of this link can be adjusted by changing the value of $returntext in pi.admin_comment.php. You can wrap as little or as much HTML around the tag as you like to ensure that the page is styled to suit your site. The user message (e.g. comment successfully deleted) will appear wherever the tag itself is placed. Currently the plugin is only designed to delete one comment at a time, so you should never embed more than one copy of the tag in a page. All of the standard user EE access checks are completed before a user is allowed to delete the comment, so ensure that your member group permissions are set very carefully.

The exact same parameter and behavior applies to the close tag: {exp:admin_comment:close returnlink="true"}

By the way, thanks to Dom Stubbs of Vaya Design for writing the Delete Entry plugin upon which a bit of this code is based.

Admin Comments
Version 1.0
Download Plugin

"A must-have plugin for Expression Engine."

Greg Storey, Airbag Industries

Flickr

slideshowrss

All articles, design, code, etc are All Rights Reserved.

Icons by iconbuffet and FAMFAMFAM. Thanks!

Snook Approved!