2017 © Pedro Peláez
 

yii2-extension yii2-socialshare

Social share widget for the Yii2 Framework

image

black-lamp/yii2-socialshare

Social share widget for the Yii2 Framework

  • Tuesday, February 28, 2017
  • by GutsVadim
  • Repository
  • 9 Watchers
  • 3 Stars
  • 753 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 17 Versions
  • 13 % Grown

The README.md

Social share widget for Yii2

This widget adds share links for social networks., (*1)

Latest Stable Version Latest Unstable Version License, (*2)

It supports from the box * VK * Facebook * Twitter * Google+ * LinkedIn * Pinterest * Telegram * Viber * WhatsApp * Gmail, (*3)

Installation

Run command

composer require black-lamp/yii2-socialshare

or add, (*4)

"black-lamp/yii2-socialshare": "1.*.*"

to the require section of your composer.json., (*5)

Add 'SocialShare' component to application config

'components' => [
    // ...
    'socialShare' => [
        'class' => bl\socialShare\SocialShare::className(),
        'defaultIcons' => true,
        'attributes' => [
            'class' => 'social-btn'
        ],
        'networks' => [
            'facebook' => [
                'class' => bl\socialShare\classes\Facebook::className(),
                'label' => 'Facebook'
            ],
            'twitter' => [
                'class' => bl\socialShare\classes\Twitter::className(),
                'label' => 'Twitter',
                // custom option for Twitter class
                'account' => 'twitterAccount'
            ],
            'googlePlus' => [
                'class' => bl\socialShare\classes\GooglePlus::className(),
                'label' => 'Google+'
            ],
            'vk' => [
                'class' => bl\socialShare\classes\Vkontakte::className(),
                'label' => 'vk'
            ],
            // other social networks ...
        ]
    ],
]

In this component you need to add and configure social network classes, (*6)

Component configuration properties

Option Description Type Default
networks Array of social networks classes configuration array -
attributes HTML attributes for all share links array -
defaultIcons Use default font-icons instead text labels or not boolean false
enableSeo Enable or disable appending SEO attributes from seoAttributes array for links boolean true
seoAttributes Array of SEO attributes for links array ['target' => '_blank', 'rel' => 'nofollow']

Social network class configuration properties

Option Description Type
class Namespace of social network class string
label Text for link string
attributes HTML attributes for share link array

Using

You should use the widget for adding the share links on page, (*7)

    <?= \bl\socialShare\widgets\SocialShareWidget::widget([
        'componentId' => 'socialShare',
        'url' => Url::toRoute(['site/index'], true),
        'title' => 'Black Lamp - digital agancy',
        'description' => 'Black Lamp provides a comprehensive range of services for development...',
        'image' => Url::toRoute(['/logo.png'], true)
    ]) ?>

Widget configuration properties

Option Description Type
componentId id of SocialShare component from config string
url Absolute URL to the page string
title Page title string
description Page description string
image Absolute URL to the image for page string
exceptions Exceptions for social networks. In this array you can override default title, description, link or image. array

What if i want to add a new social network?

You must create class and extend it from bl\socialShare\base\SocialNetwork abstract class, (*8)

use bl\socialShare\base\SocialNetwork;

class LinkedIn extends SocialNetwork
{

}

and implement the method getLink(), (*9)

class LinkedIn extends bl\socialShare\base\SocialNetwork
{
    /**
     * @inheritdoc
     */
    public function getLink($url, $title, $description, $image, $component)
    {
    }
}

this method must initialize route to the social network and return initLink() method with $component argument, (*10)

/**
 * @inheritdoc
 */
public function getLink($url, $title, $description, $image, $component)
{
    $this->_route = "https://www.linkedin.com/shareArticle?mini=true"
                    ."&url=$url"
                    ."&title=$title"
                    ."&summary=$description";

    return $this->initLink($component);
}

Other extensions

yii2-social-networks - this widget adds links to social networks, (*11)

The Versions

28/02 2017

dev-master

9999999-dev

Social share widget for the Yii2 Framework

  Sources   Download

GNU Public License

The Requires

 

by Vladimir Kuprienko

social yii2 widget share networks

28/02 2017

1.8.1

1.8.1.0

Social share widget for the Yii2 Framework

  Sources   Download

GNU Public License

The Requires

 

by Vladimir Kuprienko

social yii2 widget share networks

23/01 2017

1.8.0

1.8.0.0

Social share widget for the Yii2 Framework

  Sources   Download

GNU Public License

The Requires

 

by Vladimir Kuprienko

social yii2 widget share networks

07/11 2016

1.7.0

1.7.0.0

Social share widget for the Yii2 Framework

  Sources   Download

GNU Public License

The Requires

 

by Vladimir Kuprienko

social yii2 widget share networks

07/11 2016

1.6.0

1.6.0.0

Social share widget for the Yii2 Framework

  Sources   Download

GNU Public License

The Requires

 

by Vladimir Kuprienko

social yii2 widget share networks

29/10 2016

1.5.0

1.5.0.0

Social share widget for the Yii2 Framework

  Sources   Download

GNU Public License

The Requires

 

by Vladimir Kuprienko

social yii2 widget share networks

21/10 2016

1.4.0

1.4.0.0

Social share widget for the Yii2 Framework

  Sources   Download

GNU Public License

The Requires

 

by Vladimir Kuprienko

social yii2 widget share networks

20/10 2016

1.3.0

1.3.0.0

Social share widget for the Yii2 Framework

  Sources   Download

GNU Public License

The Requires

 

by Vladimir Kuprienko

social yii2 widget share networks

18/10 2016

1.2.0

1.2.0.0

Social share widget for the Yii2 Framework

  Sources   Download

GNU Public License

The Requires

 

by Vladimir Kuprienko

social yii2 widget share networks

11/10 2016

1.1.0

1.1.0.0

Social share widget for the Yii2 Framework

  Sources   Download

The Requires

 

by Vladimir Kuprienko

social yii2 widget share

10/10 2016

1.0.0

1.0.0.0

Social share widget for the Yii2 Framework

  Sources   Download

The Requires

 

by Vladimir Kuprienko

social yii2 widget share

02/09 2016

0.0.6

0.0.6.0

Social share widget for the Yii2 Framework

  Sources   Download

The Requires

 

by Vladimir Kuprienko

social yii2 widget share

01/09 2016

0.0.5

0.0.5.0

Social share widget for the Yii2 Framework

  Sources   Download

The Requires

 

by Vladimir Kuprienko

social yii2 widget share

01/09 2016

0.0.4

0.0.4.0

Social share widget for the Yii2 Framework

  Sources   Download

The Requires

 

by Vladimir Kuprienko

social yii2 widget share

01/09 2016

0.0.3

0.0.3.0

Social share widget for the Yii2 Framework

  Sources   Download

The Requires

 

by Vladimir Kuprienko

social yii2 widget share

01/09 2016

0.0.2

0.0.2.0

Social share widget for the Yii2 Framework

  Sources   Download

The Requires

 

by Vladimir Kuprienko

social yii2 widget share

01/09 2016

0.0.1

0.0.1.0

Social share widget for the Yii2 Framework

  Sources   Download

The Requires

 

by Vladimir Kuprienko

social yii2 widget share