GithubHelp home page GithubHelp logo

isabella232 / craft-disqusnotify Goto Github PK

View Code? Open in Web Editor NEW

This project forked from vigetlabs/craft-disqusnotify

0.0 0.0 0.0 10 KB

Notify authors when a comment is added via Disqus

License: MIT License

PHP 88.42% HTML 11.58%

craft-disqusnotify's Introduction

Disqus Notify plugin for Craft CMS 3.x

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.

  1. Open your terminal and go to your Craft project:

     cd /path/to/project
    
  2. Then tell Composer to load the plugin:

     composer require viget/craft-disqus-notify
    
  3. In the Control Panel, go to Settings → Plugins and click the “Install” button for Disqus Notify.

Configuring Disqus Notify

  1. Navigate to the plugin settings to customize the email subject and body.

  2. 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:

  1. Disqus Comment Text
  2. Entry ID
  3. 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.

craft-disqusnotify's People

Contributors

davist11 avatar leobauza avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.