nikolaposa/zf-disqus

一个方便集成Disqus小部件的ZF模块

4.0.0 2017-07-02 08:45 UTC

This package is auto-updated.

Last update: 2024-09-06 22:26:30 UTC


README

Build Status Code Quality Code Coverage Latest Version

这是一个方便集成Disqus小部件的ZF模块。

安装

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

composer require nikolaposa/zf-disqus

通过配置提供您的Disqus 短名

<?php
return [
    'disqus' => [
        'shortname' => 'your_disqus_shortname'
        //any other Disqus config can be provided here
    ],
    // ...
];

在您的 application.config.php 中启用该模块

<?php
return [
    'modules' => [
        // ...
        'ZfDisqus',
    ],
    // ...
];

用法

此模块提供了一个 Disqus 视图助手(ZfDisqus\View\Helper\Disqus),它本质上是对DisqusHelper的包装。有关可用的小部件方法的更多信息,请参阅DisqusHelper项目文档。

示例

典型示例是某些使用布局的应用程序。小部件应该在特定的模板中渲染,而Disqus资源将在布局的某个位置渲染,最常见的是在头部或尾部部分。

模板

<!-- post.phtml -->

<?php
    //Page-specific Disqus configuration
    $this->disqus()->configure([
        'identifier' => 'article_' . $this->post->id
        'title' => $this->post->title,
    ]);
?>

<article>
    <h1><?php echo $this->escapeHtml($this->post->title); ?></h1>

    <?php echo $this->post->body; ?>
</article>

<div>
    <h2>Comments:</h2>
    <!-- Thread widget HTML -->
    <?php echo $this->disqus()->thread(); ?>
</div>

布局

<!-- layout.phtml -->
<html>
    <head>
        <title>Blog</title>
    </head>

    <body>
        <?php echo $this->content; ?>

        <!-- Render Disqus JS code -->
        <?php echo $this->disqus(); ?>
    </body>
</html>

致谢

许可协议

在MIT许可证下发布 - 有关详细信息,请参阅许可证文件