'components' => [
// ...
'socialShare' => [
'class' => \ymaker\social\share\configurators\Configurator::class,
'socialNetworks' => [
'facebook' => [
'class' => \ymaker\social\share\drivers\Facebook::class,
'label' => \yii\helpers\Html::tag('i', '', ['class' => 'icon-fb']),
],
// ...
],
],
],
'components' => [
// ...
'socialShare' => [
'class' => \ymaker\social\share\configurators\Configurator::class,
'socialNetworks' => [
'facebook' => [
'class' => \ymaker\social\share\drivers\Facebook::class,
'label' => Yii::t('app', 'Facebook'),
],
// ...
],
],
],
CSS class my-facebook-icon
will be used for Facebook driver in this example.
Default icons will be used for other social networks.
'components' => [
// ...
'socialShare' => [
'class' => \ymaker\social\share\configurators\Configurator::class,
'enableIcons' => true,
'icons' => [
\ymaker\social\share\drivers\Facebook::class => 'my-facebook-icon',
],
],
],
Configure several social share components in app config
'components' => [
// ...
'socialShareBlog' => [
'class' => \ymaker\social\share\configurators\Configurator::class,
'socialNetworks' => [
'facebook' => [
'class' => \ymaker\social\share\drivers\Facebook::class,
'label' => Yii::t('app', 'Facebook'),
],
'twitter' => [
'class' => \ymaker\social\share\drivers\Twitter::class,
'label' => Yii::t('app', 'Twitter'),
],
'googlePlus' => [
'class' => \ymaker\social\share\drivers\GooglePlus::class,
'label' => Yii::t('app', '+Google'),
],
],
],
'socialShareMessangers', => [
'class' => \ymaker\social\share\configurators\Configurator::class,
'socialNetworks' => [
'telegram' => [
'class' => \ymaker\social\share\drivers\other\Telegram::class,
'label' => Yii::t('app', 'Telegram'),
],
'viber' => [
'class' => \ymaker\social\share\drivers\other\mobile\Viber::class,
'label' => Yii::t('app', 'Viber'),
],
'whatsApp' => [
'class' => \ymaker\social\share\drivers\other\mobile\WhatsApp::class,
'label' => Yii::t('app', 'Whats app'),
],
],
],
],
Call widget in view files
// blog-article.php view file
<?= \ymaker\social\share\widgets\SocialShare::widget([
'configurator' => 'socialShareBlog', // Social share component ID
'url' => \yii\helpers\Url::to('/blog', true),
'title' => 'Blog page',
'description' => 'This is blog page',
'imageUrl' => \yii\helpers\Url::to('/images/blog.png', true),
]); ?>
// main.php layout file
<?= \ymaker\social\share\widgets\SocialShare::widget([
'configurator' => 'socialShareMessangers', // Social share component ID
'url' => \yii\helpers\Url::to('/', true),
'title' => 'Site name',
'description' => 'Welcome to my site!',
'imageUrl' => \yii\helpers\Url::to('/images/hello.png', true),
]); ?>