2013-02-21 16:39:57 +01:00
|
|
|
# Configuration
|
|
|
|
|
|
|
|
## Overview
|
2010-12-13 00:48:20 +01:00
|
|
|
|
2017-01-16 20:57:37 +01:00
|
|
|
The module provides a number of built in configuration settings below are the
|
2013-05-01 08:02:11 +02:00
|
|
|
default settings
|
2010-12-13 00:48:20 +01:00
|
|
|
|
2015-04-07 05:56:00 +02:00
|
|
|
In order to add commenting to your site, the minimum amount of work necessary is to add the `CommentsExtension` to
|
|
|
|
the base class for the object which holds comments.
|
|
|
|
|
|
|
|
```yaml
|
2017-01-16 20:57:37 +01:00
|
|
|
SilverStripe\CMS\Model\SiteTree:
|
2015-04-07 05:56:00 +02:00
|
|
|
extensions:
|
2017-01-16 20:57:37 +01:00
|
|
|
- SilverStripe\Comments\Extensions\CommentsExtension
|
2015-04-07 05:56:00 +02:00
|
|
|
```
|
|
|
|
|
|
|
|
## Configuration
|
|
|
|
|
|
|
|
In order to configure options for any class you should assign the specific option a value under the 'comments'
|
|
|
|
config of the specified class.
|
|
|
|
|
|
|
|
```yaml
|
2017-01-16 20:57:37 +01:00
|
|
|
SilverStripe\CMS\Model\SiteTree:
|
2015-04-07 05:56:00 +02:00
|
|
|
extensions:
|
2017-01-16 20:57:37 +01:00
|
|
|
- SilverStripe\Comments\Extensions\CommentsExtension
|
2015-04-07 05:56:00 +02:00
|
|
|
comments:
|
2015-04-14 00:31:32 +02:00
|
|
|
enabled: true # Enables commenting to be disabled for a specific class (or subclass of a parent with commenting enabled)
|
2015-04-08 07:55:19 +02:00
|
|
|
enabled_cms: false # The 'enabled' option will be set via the CMS instead of config
|
|
|
|
require_login: false # boolean, whether a user needs to login
|
|
|
|
require_login_cms: false # The 'require_login' option will be set via the CMS instead of config
|
|
|
|
required_permission: false # required permission to comment (or array of permissions)
|
|
|
|
include_js: true # Enhance operation by ajax behaviour on moderation links
|
2015-05-04 15:13:44 +02:00
|
|
|
use_gravatar: false # set to true to show gravatar icons,
|
2015-04-08 07:55:19 +02:00
|
|
|
gravatar_size: 80 # size of gravatar in pixels. This is the same as the standard default
|
|
|
|
gravatar_default: 'identicon' # theme for 'not found' gravatar (see http://gravatar.com/site/implement/images/)
|
|
|
|
gravatar_rating: 'g' # gravatar rating. This is the same as the standard default
|
|
|
|
show_comments_when_disabled: false # when comments are disabled should we show older comments (if available)
|
|
|
|
order_comments_by: '"Created" DESC'
|
|
|
|
comments_per_page: 10
|
|
|
|
comments_holder_id: 'comments-holder' # id for the comments holder
|
|
|
|
comment_permalink_prefix: 'comment-' # id prefix for each comment. If needed make this different
|
|
|
|
require_moderation: false
|
2015-04-14 00:31:32 +02:00
|
|
|
require_moderation_nonmembers: false # requires moderation for comments posted by non-members. 'require_moderation' overrides this if set.
|
|
|
|
require_moderation_cms: false # If true, ignore above values and configure moderation requirements via the CMS only
|
|
|
|
frontend_moderation: false # Display unmoderated comments in the frontend, if the user can moderate them.
|
|
|
|
frontend_spam: false # Display spam comments in the frontend, if the user can moderate them.
|
2015-04-08 07:55:19 +02:00
|
|
|
html_allowed: false # allow for sanitized HTML in comments
|
|
|
|
html_allowed_elements:
|
|
|
|
- a
|
|
|
|
- img
|
|
|
|
- i
|
|
|
|
- b
|
|
|
|
use_preview: false # preview formatted comment (when allowing HTML). Requires include_js=true
|
2016-02-09 07:46:31 +01:00
|
|
|
nested_comments: false # If true comments can be replied to up to nested_depth levels
|
|
|
|
nested_depth: 2 # The maximum depth of the comment hierarchy for comment reply purposes
|
2015-04-07 05:56:00 +02:00
|
|
|
```
|
|
|
|
|
2015-04-08 07:55:19 +02:00
|
|
|
Enabling any of the *_cms options will instead allow these options to be configured under the settings tab
|
|
|
|
of each page in the CMS.
|
2015-04-07 05:56:00 +02:00
|
|
|
|
2017-01-16 20:57:37 +01:00
|
|
|
If you want to customize any of the configuration options after you have added
|
2013-05-01 08:02:11 +02:00
|
|
|
the extension (or on the built-in SiteTree commenting) use `set_config_value`
|
2010-12-13 00:48:20 +01:00
|
|
|
|
2015-04-07 05:56:00 +02:00
|
|
|
```yaml
|
|
|
|
# Set the default option for pages to require login
|
2017-01-16 20:57:37 +01:00
|
|
|
SilverStripe\CMS\Model\SiteTree:
|
2015-04-07 05:56:00 +02:00
|
|
|
comments:
|
|
|
|
require_login: true
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
```php
|
|
|
|
// Get the setting
|
2017-01-16 20:57:37 +01:00
|
|
|
$loginRequired = singleton('SilverStripe\\CMS\\Model\\SiteTree')->getCommentsOption('require_login');
|
2015-04-07 05:56:00 +02:00
|
|
|
```
|
|
|
|
|
2017-01-16 20:57:37 +01:00
|
|
|
|
2013-02-21 16:39:57 +01:00
|
|
|
## HTML Comments
|
|
|
|
|
2017-01-16 20:57:37 +01:00
|
|
|
Comments can be configured to contain a restricted set of HTML tags through the
|
|
|
|
`html_allowed` and `html_allowed_elements` settings. Raw HTML is hardly user
|
|
|
|
friendly, but combined with a rich-text editor of your own choosing it can
|
2013-05-01 08:02:11 +02:00
|
|
|
allow rich comment formatting.
|
2013-02-21 16:39:57 +01:00
|
|
|
|
|
|
|
In order to use this feature, you need to install the
|
2017-01-16 20:57:37 +01:00
|
|
|
[HTMLPurifier](http://htmlpurifier.org/) library. The easiest way to do this is
|
2013-05-01 08:02:11 +02:00
|
|
|
through [Composer](http://getcomposer.org).
|
2013-02-21 16:39:57 +01:00
|
|
|
|
2017-01-16 20:57:37 +01:00
|
|
|
```json
|
|
|
|
{
|
|
|
|
"require": {"ezyang/htmlpurifier": "^4.8"}
|
|
|
|
}
|
|
|
|
```
|
2013-02-21 16:39:57 +01:00
|
|
|
|
2017-01-16 20:57:37 +01:00
|
|
|
**Important**: Rendering user-provided HTML on your website always risks
|
|
|
|
exposing your users to cross-site scripting (XSS) attacks, if the HTML isn't
|
2013-05-01 08:02:11 +02:00
|
|
|
properly sanitized. Don't allow tags like `<script>` or arbitrary attributes.
|
2013-03-06 10:08:39 +01:00
|
|
|
|
|
|
|
## Gravatars
|
|
|
|
|
2016-03-21 01:31:31 +01:00
|
|
|
Gravatars can be turned on by adding this to your mysite/_config/config.yml file
|
2013-03-06 10:08:39 +01:00
|
|
|
|
2015-04-07 05:56:00 +02:00
|
|
|
```yaml
|
2017-01-16 20:57:37 +01:00
|
|
|
SilverStripe\CMS\Model\SiteTree:
|
2015-04-07 05:56:00 +02:00
|
|
|
comments:
|
2016-03-21 01:31:31 +01:00
|
|
|
use_gravatar: true
|
2015-04-07 05:56:00 +02:00
|
|
|
````
|
2013-03-06 10:08:39 +01:00
|
|
|
|
2017-01-16 20:57:37 +01:00
|
|
|
The default size is 80 pixels, as per the gravatar site if the 's' parameter is
|
2016-03-21 01:31:31 +01:00
|
|
|
omitted. To change this add the following (again to mysite/_config/config.yml):
|
2013-03-06 10:08:39 +01:00
|
|
|
|
2015-04-07 05:56:00 +02:00
|
|
|
```yaml
|
2017-01-16 20:57:37 +01:00
|
|
|
SilverStripe\CMS\Model\SiteTree:
|
2015-04-07 05:56:00 +02:00
|
|
|
comments:
|
|
|
|
gravatar_size: 40
|
|
|
|
```
|
2013-05-01 08:02:11 +02:00
|
|
|
|
2017-01-16 20:57:37 +01:00
|
|
|
If the email address used to comment does not have a gravatar, it is possible
|
|
|
|
to configure the default image shown. Valid values can be found at
|
|
|
|
http://gravatar.com/site/implement/images/, and at the time of writing are the
|
2013-05-01 08:02:11 +02:00
|
|
|
following:
|
|
|
|
|
2017-01-16 20:57:37 +01:00
|
|
|
* 404: do not load any image if none is associated with the email hash, instead
|
2013-05-01 08:02:11 +02:00
|
|
|
return an HTTP 404 (File Not Found) response.
|
2017-01-16 20:57:37 +01:00
|
|
|
* mm: (mystery-man) a simple, cartoon-style silhouetted outline of a person
|
2013-05-01 08:02:11 +02:00
|
|
|
(does not vary by email hash).
|
|
|
|
* identicon: a geometric pattern based on an email hash
|
|
|
|
* monsterid: a generated 'monster' with different colors, faces, etc
|
|
|
|
* wavatar: generated faces with differing features and backgrounds
|
|
|
|
* retro: awesome generated, 8-bit arcade-style pixelated faces
|
2017-01-16 20:57:37 +01:00
|
|
|
* blank: a transparent PNG image (border added to HTML below for demonstration
|
2013-05-01 08:02:11 +02:00
|
|
|
purposes)
|
|
|
|
|
2015-04-07 05:56:00 +02:00
|
|
|
To change the default image style, add the following to mysite/_config/config.yml
|
2013-05-01 08:02:11 +02:00
|
|
|
|
2015-04-07 05:56:00 +02:00
|
|
|
```yaml
|
2017-01-16 20:57:37 +01:00
|
|
|
SilverStripe\CMS\Model\SiteTree:
|
2015-04-07 05:56:00 +02:00
|
|
|
comments:
|
|
|
|
gravatar_default: 'retro'
|
|
|
|
```
|
2013-05-01 08:02:11 +02:00
|
|
|
|
2017-01-16 20:57:37 +01:00
|
|
|
The rating of the image can be changed by adding a line similar to this to
|
2015-04-07 05:56:00 +02:00
|
|
|
mysite/_config/config.yml
|
2013-05-01 08:02:11 +02:00
|
|
|
|
2015-04-07 05:56:00 +02:00
|
|
|
```yaml
|
2017-01-16 20:57:37 +01:00
|
|
|
SilverStripe\CMS\Model\SiteTree:
|
2015-04-07 05:56:00 +02:00
|
|
|
comments:
|
|
|
|
gravatar_rating: 'r'
|
|
|
|
```
|
2013-05-01 08:02:11 +02:00
|
|
|
|
|
|
|
Vald values for rating are as follows:
|
|
|
|
|
|
|
|
* g: suitable for display on all websites with any audience type.
|
2017-01-16 20:57:37 +01:00
|
|
|
* pg: may contain rude gestures, provocatively dressed individuals, the lesser
|
2013-05-01 08:02:11 +02:00
|
|
|
swear words, or mild violence.
|
2017-01-16 20:57:37 +01:00
|
|
|
* r: may contain such things as harsh profanity, intense violence, nudity, or
|
2013-05-01 08:02:11 +02:00
|
|
|
hard drug use.
|
2013-06-02 17:42:47 +02:00
|
|
|
* x: may contain hardcore sexual imagery or extremely disturbing violence.
|