- Drupal 7 Social Networking
- Michael Peacock
- 432字
- 2025-02-21 01:31:59
Managing comments
In Chapter 2, Preparing Drupal for a Social Networking Site, we briefly looked at all aspects of Drupal's administration area, including comments and their moderation. Now, let us look at how we can enable comments, and how they are created.
When creating content for our site (currently, either through the Add content shortcut in the administration bar, or via Content | Add content) there is a section entitled Comment settings. Clicking this brings the comment settings for the content into focus:

From here we can enable comments by selecting Open, or leave them disabled by selecting Closed. If comments are enabled, users still require the appropriate permission (Post comments) to post comments. The default option for Comment settings for creating new content is defined by the settings for the content type.
Because social networking sites rely on user contributions, collaboration, and communication, for most user created content we would want to enable comments for that content. Once comments have been enabled for a particular content element, the Add new comment form is displayed.
As we are logged in, the comment form picks up our username, and has options for providing a subject for the comment and the comment itself. Because of our permissions, we can also select the format of the text we are posting; this allows us to change the format if we want to include additional HTML tags which are not allowed by default:

Comments are threaded within Drupal, which allows our users to comment on other comments, hopefully leading to a more interesting discussion among our users. Comments can be marked as a reply to another comment by clicking the reply link within the comment in question. Replies are clearly indented to make it obvious that they are in reply to a specific comment. This is illustrated in the following screenshot:

Comments within DinoSpace!
Comments are clearly a fundamental communication feature for any site which facilitates user interaction; however, these features can easily be abused by spammers. To help protect us against spam, we should only allow logged in users to post comments.
Note
While this will help to reduce spam, there are some more effective methods which we will cover in Chapter 10, Deploying and Maintaining Our Social Network.
By requiring users to sign up and log in before allowing them to comment, we can hopefully also encourage them to visit the site again, as they can receive e-mail notifications to further comments and also receive e-mails from us as site administrators, welcoming them to the site, or updating them about goings on within our site.