keygenqt/

yii2-share2

添加社交网络分享按钮的简单方法。小部件使用Yandex的"分享"块。

安装: 79

依赖: 0

建议: 0

安全: 0

星标: 0

关注者: 2

分支: 0

开放问题: 0

类型:yii2-extension

1.0.3 2020-05-30 10:20 UTC

This package is auto-updated.

Last update: 2024-09-24 02:13:45 UTC


README

Packagist Downloads

添加社交网络分享按钮的简单方法。小部件使用Yandex的"分享"块

安装

安装此扩展的首选方法是通过composer

"require": {
    "keygenqt/yii2-share2": "*"
}

用法

use keygenqt\share2\Share2;

<?= Share2::widget([
    'size' => 40,
    'margin' => 10,
    'lang' => 'en',

    'icon_facebook' => '/images/common/fb.png',
    'icon_twitter' => '/images/common/tw.png',
    'icon_linkedin' => '/images/common/in.png',

    'soc' => [Share2::SOC_FACEBOOK, Share2::SOC_TWITTER, Share2::SOC_LINKEDIN],

    'title' => 'Yii2 Share',
    'urlImage' => Url::base(true) . '/images/yii2/preview-share2.png',
    'urlPage' => Url::base(true) . Yii::$app->request->getUrl(),

]) ?>

注意

我没有覆盖所有选项,有很多选项。只有最基本的。您可以在这里找到所有参数。

选项

const SOC_YA_COLLECTIONS = 'collections';
const SOC_VK = 'vkontakte';
const SOC_FACEBOOK = 'facebook';
const SOC_GPLUS = 'gplus';
const SOC_TWITTER = 'twitter';
const SOC_LINKEDIN = 'linkedin';
const SOC_VIBER = 'viber';
const SOC_WHATSAPP = 'whatsapp';
const SOC_SKYPE = 'skype';
const SOC_TELEGRAM = 'telegram';

某些社交网络可能不会关注传递给它们的图像参数。在这种情况下,应该使用微格式

许可证

Copyright 2017-2024 Vitaliy Zarubin

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    https://apache.ac.cn/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.