Reference

Provider

A provider represents one social media platform, such as Facebook or LinkedIn. It holds the platform’s name, brand colour and icon, and creates the buttons and share links for it. Get a provider by its handle, or loop over the providers that support a feature.

{% for provider in craft.socialShare.getShareButtonProviders() %}
    {{ provider.renderShareButton({ url: entry.url }) }}
{% endfor %}

{% set facebook = craft.socialShare.getProvider('facebook') %}
<a href="{{ facebook.getShareUrl(entry.url) }}">Share on {{ facebook.name }}</a>

Properties

name

The provider’s name, such as Facebook, used as the button label. This reads getName().

handle

The provider’s handle, such as facebook, used to fetch it in templates.

primaryColor

The provider’s brand colour as a hex value, or null when it has none.

icon

The provider’s icon as SVG markup, or null when it has none.

cpEditUrl

The URL to edit the provider’s settings in the control panel.

Methods

isConfigured()

Returns whether the provider has the settings it needs, such as API credentials, to fetch follower or share counts.

getShareUrl()

Returns: string|null

Returns the link that shares a URL on the provider, or null when the provider doesn’t support sharing.

getShareButton()

Returns: verbb\socialshare\models\ShareButton|null

Returns a Share Button for the provider, without rendering it.

renderShareButton()

Returns: Twig\Markup|null

Returns the HTML for a Share Button for the provider.

getButton()

Returns: verbb\socialshare\models\Button|null

Returns a Button for the provider, without rendering it.

renderButton()

Returns: Twig\Markup|null

Returns the HTML for a Button for the provider.