viget / craft-disqus-notify
Notify authors when a comment is added via Disqus.
Installs: 1 134
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 16
Forks: 1
Open Issues: 0
Type:craft-plugin
Requires
- craftcms/cms: ^3.0.0-RC1
This package is auto-updated.
Last update: 2024-10-25 10:54:13 UTC
README
Notify authors when a comment is added via Disqus.
Requirements
This plugin requires Craft CMS 3.0.0-beta.23 or later.
Installation
To install the plugin, follow these instructions.
-
Open your terminal and go to your Craft project:
cd /path/to/project
-
Then tell Composer to load the plugin:
composer require viget/craft-disqus-notify
-
In the Control Panel, go to Settings → Plugins and click the “Install” button for Disqus Notify.
Configuring Disqus Notify
-
Navigate to the plugin settings to customize the email subject and body.
-
Signup for a Disqus account and configure for your site.
Using Disqus Notify
You will utilize the Disqus onNewComment
callback to make an AJAX request to the Disqus Notify plugin.
You need to pass the following pieces of data to the plugin:
- Disqus Comment Text
- Entry ID
- Entry Author ID
The URL that you need to POST
to is {{ actionUrl("disqus-notify/notify/notify") }}
Here is an example of the plugin in action utilizing jQuery:
<script> var disqus_config = function () { this.page.identifier = '{{ entry.id }}'; this.callbacks.onNewComment = [function(comment) { var csrfTokenName = "{{ craft.config.get('csrfTokenName') }}"; var csrfTokenValue = "{{ craft.request.getCsrfToken }}"; var data = { comment: comment.text, entryId: {{ entry.id }}, authorId: {{ entry.author.id }} }; data[csrfTokenName] = csrfTokenValue; $.post('{{ actionUrl("disqus-notify/notify/notify") }}', data); }]; }; (function() { // DON'T EDIT BELOW THIS LINE var d = document, s = d.createElement('script'); s.src = '//subdomain.disqus.com/embed.js'; s.setAttribute('data-timestamp', +new Date()); (d.head || d.body).appendChild(s); })(); </script>
Note: you will need to update your Disqus subdomain in this code snippet.