Giter VIP home page Giter VIP logo

disqus's Introduction

Disqus Module

Disqus module for Drupal 8. Disqus is a popular 3rd party commenting system for websites and online communities.

For a full description visit the project page: http://drupal.org/project/project Bug reports, feature suggestions and latest developments: http://drupal.org/project/issues/disqus

Installation

  1. Download and enable the module.
  2. Register your websites shortname on Disqus.com
  3. In the Disqus configuration, set the shortname to what you registered with Disqus.
  4. Disqus comments can be enabled for any entity sub-type (for example, a content type). On the Manage fields page for each entity sub-type,you can enable disqus by adding a Disqus comments field.
  5. Alternatively disqus comments can be used on Blocks. You will first need to configure the disqus comment field for any entity sub-type.
  6. Visit the permissions, and set which users you would like to have the ability to view Disqus threads (recommended for role).

Additional Requirements

For using the Disqus API to communicate with the Disqus data you will need to download the Disqus API bindings. Disqus module uses the api for updating/deleting disqus threads on updation/deletion of entities on your Drupal site. Also for migration of comments from a Drupal site to Disqus and vice-versa requires the Disqus API bindings.

Follow the steps below to download the Disqus API bindings:

  1. You will need to install the Composer Manager module. Also make sure you have drush installed (Drush is a command-line shell and scripting interface for Drupal).
  2. Obtain your user access key from the application specific page http://disqus.com/api/applications/.
  3. Now run the following commands from within your Drupal root directory to download the DisqusAPI bindings:
  // Rebuild the composer.json file with updated dependencies
  $ drush composer-json-rebuild
  // Install the required packages
  $ drush composer-manager install

Built-in Features

  • This module automatically updates and/or delete your Disqus threads when you delete/update the entities for which disqus field is enabled.
  • Visit Disqus configuration page after you have installed Disqus API to configure it's behaviour.

Note: Using this feature also requires the public_key orsecret_key

  • Tracking new comments and replies via "Google Analytics" analytic service.

####Examples You can find the API reference here : http://disqus.com/api/docs/ Any of these methods can be called by creating an instance of the Disqus API through disqus_api(). You must use try/catch to avoid php throwing a general exception and stopping script execution.

For a full explanation of the official API you can view the readme located here:

https://github.com/disqus/disqus-php/blob/master/README.rst

Example: Calling threads->details and threads->update

  $disqus = disqus_api();
  if ($disqus) {
    try {
      // Load the thread data from disqus. Passing thread is required to allow
      // the thread:ident call to work correctly. There is a pull request to fix
      // this issue.
      $thread = $disqus->threads->details(
        array(
            'forum' => $config->get('disqus_domain'),
         'thread:ident' => "{$entity->getEntityTypeId()}/{$entity->id()}",
         'thread' => '1'));
    }
    catch (Exception $exception) {
      drupal_set_message(t('There was an error loading the thread details from
      Disqus.'), 'error');
      \Drupal::logger('disqus')->error('Error loading thread details for entity
      : !identifier. Check your API keys.',
       array(
        '!identifier' => "{$entity->getEntityTypeId()}/{$entity->id()}"
       ));
    }
    if (isset($thread->id)) {
      try {
        $disqus->threads->update(array(
         'access_token' => $config->get('advanced.disqus_useraccesstoken'),
         'thread' => $thread->id, 'forum' => $config->get('disqus_domain'),
         'title' => $entity->label(),
         'url' => $entity->url('canonical',array('absolute' => TRUE))
        ));
      }
      catch (Exception $exception) {
        drupal_set_message(t('There was an error updating the thread details on
        Disqus.'), 'error');
        \Drupal::logger('disqus')->error('Error updating thread details for
        entity : !identifier. Check your user access token.',
        array(
         '!identifier' => "{$entity->getEntityTypeId()}/{$entity->id()}"
        ));
      }
    }
  }

disqus's People

Contributors

jayeshsolanki93 avatar robloach avatar slashrsm avatar

Watchers

 avatar James Cloos 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.