Download the PHP package knplabs/knp-disqus-bundle without Composer
On this page you can find all versions of the php package knplabs/knp-disqus-bundle. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package knp-disqus-bundle
KnpDisqusBundle
If you use Disqus on your website for comments the comments are loaded dynamically via JavaScript, which could negatively impact SEO.
This bundle will fetch the comments using Disqus API so that you can include
them on your page… before replacing the comment div
by the Disqus JavaScript widget.
This way you benefit from both the JavaScript widget and the robot-friendly comments.
Requirements
- Disqus API: public key
Installation
With composer, run:
composer require knplabs/knp-disqus-bundle
If you're not using Symfony Flex, then you will also need to enable
Knp\Bundle\DisqusBundle\KnpDisqusBundle
in your bundles.php
file.
Next, create a config/packages/knp_disqus.yaml
file:
And finally, configure the DISQUS_API_KEY
in your .env
or .env.local
file:
Usage:
In your Twig template:
You can also show comments for specific language:
Or in Controller:
Adding a Callback for New Comments
If you want a JavaScript function to be called when a new comment is added
(e.g. to trigger some Analytics), first, create a global JavaScript function
somewhere (i.e. one that is attached to the windows
object):
Next, pass the function name when rendering:
SSO authentication (optional)
If you want to manage authentication through Disqus SSO mechanism, you have to add the application secret key in the configuration and pass user information (id, username, email) which will compose the HMAC payload from it, as well as specific login/logout service information to the helper. Make sure to setup your Disqus forum to use SSO and allow for local domains (for development purposes).
To use SSO auth, pass sso.user
information in the parameters to tell Disqus which user is logged in. Pass a user with an empty id
to force Disqus to logout user, respectively to tell Disqus no user is logged in through SSO. Add information regarding your SSO Authentication service (login/logout urls, icon, etc.) in the sso.service
parameter. See Disqus SSO documentation for more information.
Configuration
Enjoy!