Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/neemzy/share-extension
Twig extension providing social sharing links
https://github.com/neemzy/share-extension
Last synced: 21 days ago
JSON representation
Twig extension providing social sharing links
- Host: GitHub
- URL: https://github.com/neemzy/share-extension
- Owner: neemzy
- License: mit
- Created: 2014-08-06T21:14:32.000Z (almost 10 years ago)
- Default Branch: master
- Last Pushed: 2015-11-19T18:13:56.000Z (over 8 years ago)
- Last Synced: 2024-05-14T00:34:14.682Z (about 1 month ago)
- Language: PHP
- Homepage:
- Size: 15.6 KB
- Stars: 13
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Lists
- awesome-twig - Share - Twig extension providing social share links (Twig / Extensions)
- awesome-twig - Share - Twig extension providing social share links (Twig / Extensions)
README
# ShareExtension
Twig extension providing social sharing links
## Why?
Using this library instead of widgets provided by social platforms will allow you to get rid of:
- JavaScript execution timing issues
- Appearance constraints
- Abusive user tracking## Installation
```
composer require neemzy/share-extension
```## Usage
This library uses [PHP SocialShare](https://github.com/dunglas/php-socialshare) internally, and allows you to generate a sharing link and retrieve a share count for any of the providers it supports ([see the list](https://github.com/dunglas/php-socialshare#php-socialshare)).
You can also generate the contents for a `onclick` handler to make your sharing link a popup on JavaScript-capable browsers, which will use each provider's ideal popup size if available. The handler relies on the link's `href` attribute in order to be able to degrade gracefully, so be sure to use it in conjunction with the URL generation.
Provider-specific parameters (e.g. tweet contents for Twitter) are supported: [see the list](https://github.com/dunglas/php-socialshare/blob/master/examples/buttons.php).
```php
use Neemzy\Twig\Extension\Share\ShareExtension;// You can get a ready-to-use instance...
$shareExtension = ShareExtension::getInstance();// ...or instantiate it yourself
$shareExtension = new ShareExtension($phpSocialShareInstance);$twig->addExtension($shareExtension);
``````twig
Share on Facebook
Share on Twitter with some text
Share on Google+ in a popupShared on Pinterest {{ share_count_pinterest(my_url) }} times.
```