2017 © Pedro Peláez
 

library share-extension

Twig extension providing social share links

image

neemzy/share-extension

Twig extension providing social share links

  • Thursday, November 19, 2015
  • by neemzy
  • Repository
  • 1 Watchers
  • 14 Stars
  • 2,918 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 3 Forks
  • 0 Open issues
  • 6 Versions
  • 25 % Grown

The README.md

ShareExtension

Twig extension providing social sharing links, (*1)

Why?

Using this library instead of widgets provided by social platforms will allow you to get rid of:, (*2)

  • JavaScript execution timing issues
  • Appearance constraints
  • Abusive user tracking

Installation

composer require neemzy/share-extension

Usage

This library uses 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)., (*3)

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., (*4)

Provider-specific parameters (e.g. tweet contents for Twitter) are supported: see the list., (*5)

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);
<a href="{{ share_url_facebook(my_url) }}">Share on Facebook</a>
<a href="{{ share_url_twitter(my_url, { 'text': 'Some text' }) }}">Share on Twitter with some text</a>
<a href="{{ share_url_google(my_url) }}" onclick="{{ share_click_google() }}">Share on Google+ in a popup</a>
<div>Shared on Pinterest {{ share_count_pinterest(my_url) }} times.</div>

The Versions

19/11 2015

dev-master

9999999-dev

Twig extension providing social share links

  Sources   Download

MIT

The Requires

 

by Avatar neemzy

19/11 2015

1.0.0

1.0.0.0

Twig extension providing social share links

  Sources   Download

MIT

The Requires

 

by Avatar neemzy

14/09 2015

0.2.2

0.2.2.0

Twig extension providing social share links

  Sources   Download

MIT

The Requires

 

by Avatar neemzy

13/09 2015

0.2.1

0.2.1.0

Twig extension providing social share links

  Sources   Download

MIT

The Requires

 

by Avatar neemzy

10/09 2015

0.2.0

0.2.0.0

Twig extension providing social share links

  Sources   Download

MIT

The Requires

 

by Avatar neemzy

09/09 2015

0.1.0

0.1.0.0

Twig extension providing social share links

  Sources   Download

The Requires

 

by Avatar neemzy