Some Web sites let people comment on pages. Drupal lets you add that feature to your IS.
You enable comments by adding a comment field to a content type. If you wanted to let people comment on projects, you would have to add a comment field to the project type.
Once you have a comment field on a content type, you can control whether each node allows comments. For example, you have two projects, Hang the Lawyers, and Hang the Demons. One of them might attract comments from trolls. You can turn comments off for that project, but leave comments open for the other.
You need to decide:
- Who gets to see comments.
- Who gets to add comments.
- Whether comments have to be approved before they show on the IS.
- Who gets to approve comments.
- What type of data comments can contain. For example, you can let people add pictures to comments. Or not.
Adding comment fields to content types
This ain’t no thing, honey! Go to Structure | Content types, pick your content type, Manage fields, and Add field. Select Comment as the field type.
Give it a label, as usual.
Now Field settings. You can create more than one comment type, adding your own fields to it. Let’s just use the default comment type.
Now some more settings.
The default in the image says that new nodes will have comments on by default. If you want to turn them off for one of the nodes, you need to edit the node.
You get to control where the comments appear on nodes. Usually, they’re after everything else.
Your choice, though.
Comments are fields on nodes
If you add the field Tongue length to the sloths content type, every sloth node has that field. The field’s value could be 4 inches for one sloth, 6 inches for another, and 5 inches for yet another.
It’s the same with comments. When you add a comment field to project, each project has the field. Comments can be turned on and off separately for each node. For example, here’s the project Eros Esse Valde:
People can add comments to the project. Here’s project Ideo Odio:
The comments are hidden. Nobody can add comments, and any comments that were already made are not displayed.
Permissions
Permissions. You need ‘em. Check these out.
Anonymous users can see comments and post comments. Skip comment approval isn’t checked for anons, so their comments are not shown right away. They need to be approved.
Org managers can Administer comments and comment settings. That means they can approve comments posted by anons. Org managers have Skip comment approval. So when they post comments, the comments appear immediately.
Approving comments
In the admin menu, Content | Comments | Unapproved comments shows Org managers the comments they need to check.
You can figure out how it works.
In an exercise earlier, you made a control panel, a menu for managers to use. There’s one on Gamerz, too. Log in as an org manager, and you’ll see it. Go to the login page. (https://gamerz.cybercour.se/user/login) Log in with the user name manager
, and the password password
.
There’s a link to the comment approval page at the bottom.
How to add a link like that? The CP is a menu. Go to Structure | Menus, and add a link to the CP menu.
We need to know the URL of the comment approval page. Easy. Just go to the page, and look at the URL:
Use the URL for the new menu link, without the domain name:
That’s it! W00t!
Text formats
So, anons can post comments on projects. Org managers can approve them. Cool.
Another question. Can anons put anything in a comment, like photos? Just plain text? What?
Remember that there are text formats, also called filters. Full HTML lets people type any HTML. Restricted HTML lets them use just a few tags. Plain text means they can’t type any HTML tags at all. Just, er, plain text.
Here’s what the new comment form looks to anons:
There’s no toolbar in the comment field. Just a place to type. That’s it.
The Projects view
The Gamerz IS has a view that shows a list of projects. Let’s add a comment count:
Turns out that Views already knows how to count comments. It has a special field for it.
Open the view, and add the field:
It doesn’t have many settings. Let’s just give it a label.
Move the field to the right spot:
Recall that Org managers see an Edit link for each project. I put the comment count above that.
Save the view, and we’re done. Woohoo!
Exercises
- Anons can see and make comments, but they have to be approved.
- Create a role called Social manager. Users with that role can approve comments. They can post comments without approval.
- Anons can use the Restricted HTML filter.
- Add CAPTCHA to comment forms. Hint: try “comment_comment_form” for the CAPTCHA point.
(If you were logged in as a student, you could submit an exercise solution, and get some feedback.)
- A table
- Initially sorted by comments, descending
- User can click on the column headings to sort
- Header text
(If you were logged in as a student, you could submit an exercise solution, and get some feedback.)
Summary
You can add a comments field to a content type. Permissions control who can see and add comments, whether approvals are skipped, and who gets to approve comments. You can add comment counts to views.