nikolaposa/disqus-helper

PHP library which facilitates integration of Disqus widgets.

2.1.2 2017-01-01 15:40 UTC

This package is auto-updated.

Last update: 2024-11-06 23:01:13 UTC


README

Build Status Scrutinizer Code Quality Code Coverage Latest Stable Version PDS Skeleton

PHP library which facilitates integration of Disqus widgets.

Installation

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

Usage

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.

Author

Nikola Poša

Copyright and license

Copyright 2017 Nikola Poša. Released under MIT License - see the LICENSE file for details.