Krajee
Thankful to Krajee! BUY A COFFEEor to get more out of us.
This widget embeds the Disqus comments plugin into your website.

Tip

Not seeing the updated content on this page! Hard refresh your browser to clean cache for this page (e.g. SHIFT-F5 on Windows Chrome)

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="https://foo.com/bar.html#disqus_thread">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="https://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
]);

yii2-social is released under the BSD-3-Clause License. See the bundled LICENSE.md for details.

Note

You can now visit the Krajee Webtips Q & A forum for searching OR asking questions OR helping programmers with answers on these extensions and plugins. For asking a question click here. Select the appropriate question category (i.e. Krajee Plugins) and choose this current page plugin in the question related to field.

The comments and discussion section below are intended for generic discussions or feedback for this plugin. Developers may not be able to search or lookup here specific questions or tips on usage for this plugin.

 
visitors to Krajee Yii2 Demos since 22-May-2017