PHP library which facilitates integration of Disqus widgets.
The preferred method of installation is via Composer. Run the following
command to install the latest version of a package and add it to your project's composer.json
:
composer require nikolaposa/disqus-helper
Initialization
use DisqusHelper\Disqus;
$disqus = Disqus::create('disqus_shortname');
Template
<html>
<head>
<title>Blog</title>
<?php
//Page-specific Disqus configuration
$disqus->configure([
'page.identifier' => 'article1',
'page.title' => 'My article',
]);
?>
</head>
<body>
<article>
<h1>My article</h1>
<!-- Comments count widget -->
<?php echo $disqus->commentsCount(['url' => 'http://example.com/article1.html']); ?>
<p>My article text</p>
</article>
<div>
<h2>Comments:</h2>
<!-- Thread widget -->
<?php echo $disqus->thread(); ?>
</div>
<!-- MUST be called at the end, usually before closing </body> tag -->
<?php echo $disqus->getCode(); ?>
</body>
</html>
See more examples.
Nikola Poša
Copyright 2017 Nikola Poša. Released under MIT License - see the LICENSE
file for details.