nikolaposa/disqus-helper

PHP 库,简化 Disqus 小部件的集成。

2.1.2 2017-01-01 15:40 UTC

This package is auto-updated.

Last update: 2024-09-06 22:40:24 UTC


README

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

PHP 库,简化Disqus小部件的集成。

安装

推荐通过 Composer 安装。运行以下命令以安装最新版本的包并将其添加到项目的 composer.json

composer require nikolaposa/disqus-helper

使用方法

初始化

use DisqusHelper\Disqus;

$disqus = Disqus::create('disqus_shortname');

模板

<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>

查看更多示例 .

作者

Nikola Poša

版权和许可证

版权所有 2017 Nikola Poša。在 MIT 许可证下发布 - 有关详细信息,请参阅 LICENSE 文件。