2013-02-21 16:39:57 +01:00
|
|
|
# Configuration
|
|
|
|
|
|
|
|
## Overview
|
2010-12-13 00:48:20 +01:00
|
|
|
|
2013-05-01 08:02:11 +02:00
|
|
|
The module provides a number of built in configuration settings below are the
|
|
|
|
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
|
|
|
|
SiteTree:
|
|
|
|
extensions:
|
|
|
|
- CommentsExtension
|
|
|
|
```
|
|
|
|
|
|
|
|
## 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
|
|
|
|
SiteTree:
|
|
|
|
extensions:
|
|
|
|
- CommentsExtension
|
|
|
|
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
|
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
|
|
|
|
2013-05-01 08:02:11 +02:00
|
|
|
If you want to customize any of the configuration options after you have added
|
|
|
|
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
|
|
|
|
SiteTree:
|
|
|
|
comments:
|
|
|
|
require_login: true
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
```php
|
|
|
|
// Get the setting
|
|
|
|
$loginRequired = singleton('SiteTree')->getCommentsOption('require_login');
|
|
|
|
```
|
|
|
|
|
2010-12-13 00:48:20 +01:00
|
|
|
|
2013-02-21 16:39:57 +01:00
|
|
|
## HTML Comments
|
|
|
|
|
2013-05-01 08:02:11 +02: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
|
|
|
|
allow rich comment formatting.
|
2013-02-21 16:39:57 +01:00
|
|
|
|
|
|
|
In order to use this feature, you need to install the
|
2013-05-01 08:02:11 +02:00
|
|
|
[HTMLPurifier](http://htmlpurifier.org/) library. The easiest way to do this is
|
|
|
|
through [Composer](http://getcomposer.org).
|
2013-02-21 16:39:57 +01:00
|
|
|
|
|
|
|
{
|
|
|
|
"require": {"ezyang/htmlpurifier": "4.*"}
|
|
|
|
}
|
|
|
|
|
2013-05-01 08:02:11 +02: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
|
|
|
|
properly sanitized. Don't allow tags like `<script>` or arbitrary attributes.
|
2013-03-06 10:08:39 +01:00
|
|
|
|
|
|
|
## Gravatars
|
|
|
|
|
|
|
|
Gravatars can be turned on by adding this to your mysite/_config.php file
|
|
|
|
|
2015-04-07 05:56:00 +02:00
|
|
|
```yaml
|
|
|
|
SiteTree:
|
|
|
|
comments:
|
|
|
|
use_gravitar: true
|
|
|
|
````
|
2013-03-06 10:08:39 +01:00
|
|
|
|
2013-05-01 08:02:11 +02:00
|
|
|
The default size is 80 pixels, as per the gravatar site if the 's' parameter is
|
|
|
|
omitted. To change this add the following (again to mysite/_config.php):
|
2013-03-06 10:08:39 +01:00
|
|
|
|
2015-04-07 05:56:00 +02:00
|
|
|
```yaml
|
|
|
|
SiteTree:
|
|
|
|
comments:
|
|
|
|
gravatar_size: 40
|
|
|
|
```
|
2013-05-01 08:02:11 +02: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
|
|
|
|
following:
|
|
|
|
|
|
|
|
* 404: do not load any image if none is associated with the email hash, instead
|
|
|
|
return an HTTP 404 (File Not Found) response.
|
|
|
|
* mm: (mystery-man) a simple, cartoon-style silhouetted outline of a person
|
|
|
|
(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
|
|
|
|
* blank: a transparent PNG image (border added to HTML below for demonstration
|
|
|
|
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
|
|
|
|
SiteTree:
|
|
|
|
comments:
|
|
|
|
gravatar_default: 'retro'
|
|
|
|
```
|
2013-05-01 08:02:11 +02: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
|
|
|
|
SiteTree:
|
|
|
|
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.
|
|
|
|
* pg: may contain rude gestures, provocatively dressed individuals, the lesser
|
|
|
|
swear words, or mild violence.
|
|
|
|
* r: may contain such things as harsh profanity, intense violence, nudity, or
|
|
|
|
hard drug use.
|
2013-06-02 17:42:47 +02:00
|
|
|
* x: may contain hardcore sexual imagery or extremely disturbing violence.
|