Disqus comments for laravel 4
Add the package in your composer.json file and run composer update
.
{
"require": {
"d-te/laravel-discus": "dev-master"
}
}
Register the service provider within the providers
array found in app/config/app.php
:
'providers' => array(
// ...
'Dte\Disqus\DisqusServiceProvider'
)
Add an alias within the aliases
array found in app/config/app.php
:
'aliases' => array(
// ...
'Disqus' => 'Dte\Disqus\Facades\Disqus',
)
Create configuration file for package using artisan command
$ php artisan config:publish d-te/laravel-disqus
Add 'disqus_shortname' to app/config/packages/d-te/laravel-disqus/config.php
.
You can find your disqus shortname afer signing up and visiting https://disqus.com/admin/settings/
In your template add :
{{ \Disqus::comments() }}
There are some disqus configuration variables:
- disqus_identifier
- disqus_title
- disqus_url
- disqus_category_id
Example of usage:
{{ \Disqus::comments(
array(
'disqus_identifier' => '/december-2010/the-best-day-of-my-life/',
'disqus_title' => 'Some title',
'disqus_url' => 'http://example.com/helloworld.html',
'disqus_category_id' => 123456
) ) }}
There are two ways how to change disqus locales:
- To switch on auto selecting disqus language based on Laravel app locale:
in app/config/packages/d-te/laravel-disqus/config.php
set
'auto_set_language' => true,
- Set locale manually in template:
{{ \Disqus::comments(array('language' => 'de')) }}
Sometimes discus locale could not corresponde to your app locale.
To convert your app locale to discus locale just add supported locales to config app/config/packages/d-te/laravel-disqus/config.php
example:
'discus_languages' => array(
'ua' => 'uk',
'fr' => 'fr_CA',
)