This bundle provides a simple way to integrate a bar of social buttons to share your pages on Facebook, Twitter, Google Plus and Linkdein.
You also have a social links bar to networks., (*1)
Introduction
I have not found any Symfony2 bundle to respond to this common need: display "share", "like"... buttons with an easy integration into templates.
It is intended to evolve :
- manage more networks
- use custom icons
- compatibility with php templates
- suggestions are welcome, (*2)
Yann, (*3)
Requirements
Installation
Add this line to require section of your composer.json
``` js
{
//...
"require": {
//...
"nomaya/social-bundle": "dev-master"
}
}, (*4)
### Install the bundle
``` bash
$ curl -s http://getcomposer.org/installer | php
$ php composer.phar update nomaya/social-bundle
Composer will install the bundle to your project's vendor/nomaya
directory., (*5)
Enable the bundle via the kernel
``` php
<?php
// app/AppKernel.php, (*6)
public function registerBundles()
{
$bundles = array(
// ...
new Nomaya\SocialBundle\NomayaSocialBundle(),
);
}, (*7)
Get the options details :
- https://developers.facebook.com/docs/plugins/like-button
- https://developers.google.com/+/web/+1button/
- https://about.twitter.com/resources/buttons
- https://developer.linkedin.com/plugins/share-plugin-generator
- ..., (*8)
Twig extension
The bundle provides a Twig extension for quickly generating the buttons., (*9)
``` twig
// buttons, (*10)
// Insert the whole bar
"{{ socialButtons() }}", (*11)
// Insert only one button
"{{ twitterButton() }}"
// or
"{{ socialButtons( {'googleplus':false, 'facebook':false, 'linkedin':false} ) }}", (*12)
// insert the google+ button with custom parameters
"{{ googlePlusButton( {'locale':'fr', 'url':'http://google.fr' }) }}", (*13)
// insert the bar with specific values for Facebook
"{{ socialButtons( { 'facebook': {'locale':'fr_FR', 'send':true}} ) }}", (*14)
// links, (*15)
// insert the whole links defined in config
"{{ sociallinks() }}", (*16)
// insert one link, no option
"{{ socialLink('facebook') }}", (*17)
// insert one link, specifying the url
"{{ socialLink('linkedin',{'url': 'http://www.nomaya.net'}) }}", (*18)
// insert custom bar with 2 links, not showing googleplus
"{{ socialLinks({'linkedin',{'url': 'http://www.nomaya.net'}, 'facebook':{'url': 'http://www.facebook.com'}, 'googleplus': false}) }}"
```, (*19)
Notes
Pull requests a very welcome to integrate more buttons to this extension., (*20)
Thanks to Gregquat for his article: http://obtao.com/blog/2012/11/social-buttons-bar-for-facebook-twitter-google-with-symfony/ which did most of the work., (*21)
License
This bundle is under the MIT license. See the complete license in the bundle:, (*22)
Resources/meta/LICENSE