nikolaposa / zf-disqus
一个方便集成Disqus小部件的ZF模块
4.0.0
2017-07-02 08:45 UTC
Requires
- php: ^7.0
- nikolaposa/disqus-helper: ^2.0
- zendframework/zend-servicemanager: ^3.0
- zendframework/zend-view: ^2.7
Requires (Dev)
- friendsofphp/php-cs-fixer: ^2.0
- phpunit/phpunit: ^5.7 || ^6.0
- zendframework/zend-i18n: ^2.7
- zendframework/zend-modulemanager: ^2.7
- zendframework/zend-mvc: ^3.0
README
这是一个方便集成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许可证下发布 - 有关详细信息,请参阅许可证文件。