Social Details Disqus Widget

Latest Stable Version Latest Unstable Version Total Downloads Monthly Downloads Daily Downloads
Thankful to Krajee!
to get more out of us.

NOTE: This extension depends on the kartik-v/yii2-krajee-base extension which in turn depends on the yiisoft/yii2-bootstrap extension. Check the composer.json for this extension's requirements and dependencies that may be updated by composer.

This widget embeds the Disqus comments plugin into your website.

The Disqus widget supports these parameters.
  • settings: array the plugin settings for the Disqus widget. The following options are recognized:

    • shortname: string the Disqus forum's shortname, which is the unique identifier for your website as registered on Disqus. If not set, the widget will attempt to use the configuration settings from the module. If undefined, an exception will be raised.

    • identifier: string tells the Disqus service how to identify the current page. When the Disqus embed is loaded, the identifier is used to look up the correct thread. If identifier is undefined, the page's URL will be used. The URL can be unreliable, such as when renaming an article slug or changing domains, so we recommend using your own unique way of identifying a thread.

    • title: string tells the Disqus service the title of the current page. This is used when creating the thread on Disqus for the first time. If undefined, Disqus will use the <title> attribute of the page. If that attribute could not be used, Disqus will use the URL of the page.

    • url: string tells the Disqus service the URL of the current page. If undefined, Disqus will take the window.location.href. This URL is used to look up or create a thread if identifier is undefined. In addition, this URL is always saved when a thread is being created so that Disqus knows what page a thread belongs to.

    • category_id: integer tells the Disqus service the category to be used for the current page. This is used when creating the thread on Disqus for the first time. If undefined, Disqus will use the forum's default General category.

    • disable_mobile: boolean tells the Disqus service to never use the mobile optimized version of Disqus. Defaults to true

  • showCount: boolean whether to display the comment count summary instead of the detailed Disqus standard comments widget. This is effective when you append #disqus_thread to the href attribute in your links. This will tell Disqus which links to look up and return the comment count. For example: <a href="">Link</a>.

  • noscript: string/boolean text to be displayed if browser does not support javascript. If set to false will not displayed. Defaults to Please enable JavaScript to view the comments powered by disqus.

  • noscriptOptions: array the HTML attributes for the noscript message container. Defaults to ['class' => 'alert alert-danger']

NOTE You can configure the Disqus settings once at the social module configuration level, for defaulting it across your application, and skip it in your widget calls. For example.
// your module config
'modules' => [
    'social' => [
        // the module class
        'class' => 'kartik\social\Module',

        // the global settings for the disqus widget
        'disqus' => [
            'settings' => ['shortname' => 'DISQUS_SHORTNAME'] // default settings

// your call in your view/layout file
echo Disqus::widget([]); // will use the disqus settings configured in module

You can setup the Disqus widget in your view layout file or your view like below:

  • Comments/Disqussion Thread: An example output of the complete Disqus Comments/Disqussion Thread can be seen at the bottom of this page.
  • Comment Counts: An example output of displaying only the Disqus Comment Counts can be seen at the top right of the navigation menu above. In order to display only counts, call the widget with showCount as true. Then, the comment counts can be embedded by appending #disqus_thread to your comment source links. For example:<a href="http://your-page-link-with-comments#disqus_thread"></a>
use kartik\social\Disqus;

// If any parameters are not passed, the widget will use settings 
// from the social module wherever possible
echo Disqus::widget();

// Basic widget usage
echo Disqus::widget([
    'settings' => ['shortname' => 'YOUR_DISQUS_SHORTNAME']

// Advanced widget usage
echo Disqus::widget([
    'settings' => ['shortname' => 'YOUR_DISQUS_SHORTNAME', 'identifier'=>'UNIQUE_ID', 'url'=>'SOURCE_URL'],

// Show only comment count
echo Disqus::widget([
    'settings' => ['shortname' => 'YOUR_DISQUS_SHORTNAME'],
    'showCount' => true