Disqus Widget

What is the DISQUS Widget?

The DISQUS widget helps you to implement the comment stream service DISQUS in your Yii 2 applications.

Installation

The preferred way to install this extension is through composer.

Either run

composer require 2amigos/yii2-disqus-widget:~1.0

or add the following to the require section of your application's composer.json file:

"2amigos/yii2-disqus-widget" : "~1.0"

Usage example

There are two widgets:

  • Comments: Displays the comment stream
  • CommentsCount: The number of comments that a specific stream has

Comments Widget

<?php
use dosamigos\disqus\Comments;

echo Comments::widget([
    // see http://help.disqus.com/customer/portal/articles/472098-javascript-configuration-variables
    'shortname' => '{yourforumshortname}',
    'identifier' => 'article_identifier'
]);
?>

CommentsCount Widget

To display DISQUS comments count, first setup the link where you wish to display the comments (visit DISQUS integration).

By default DISQUS looks up the count using the comment count links href attribute. However, the count can also be looked up using a DISQUS identifier:

<a href="http://example.com/#disqus_thread">article</a>

After that, we can just make use of the CommentsCount widget:

<?php 
use dosamigos\disqus\CommentsCount;

CommentsCount::widget([
    'shortname' => '{yourforumshortname}',
    'identifier' => 'article_identifier'
]);
?>

Share this

Contributors Thanks All

 

Do you have a good idea? Why Don't We Talk?