tmukherjee13/yii2-socialshare
Composer 安装命令:
composer require tmukherjee13/yii2-socialshare
包简介
Social share widget for the Yii2 Framework
README 文档
README
This widget adds share links for social networks.
It supports from the box
- VK
- Google+
- Telegram
- Viber
- Gmail
Installation
Run command
composer require tmukherjee13/yii2-socialshare
or add
"tmukherjee13/yii2-socialshare": "1.*"
to the require section of your composer.json.
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
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
<?= \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
use bl\socialShare\base\SocialNetwork; class LinkedIn extends SocialNetwork { }
and implement the method getLink()
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
/** * @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); }
UPDATE
This fork fixes the conflict of using Object in classes since in PHP 7.2 Object is a reserved keyword.
Other extensions
yii2-social-networks - this widget adds links to social networks
tmukherjee13/yii2-socialshare 适用场景与选型建议
tmukherjee13/yii2-socialshare 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 24 次下载、GitHub Stars 达 0, 最近一次更新时间为 2019 年 09 月 26 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「social」 「widget」 「share」 「networks」 「yii2」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 tmukherjee13/yii2-socialshare 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 tmukherjee13/yii2-socialshare 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 tmukherjee13/yii2-socialshare 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Simple Sharing generates social media share links within CP entry pages, allowing you to quickly & easily share entries.
Yii2 LightBox image galary widget uses Lightbox v2.10.0 by Lokesh Dhakar
Improves silverstripes html meta data options.
LinkedIn integration for Social
Autogenerated open graph images for your entries.
Add a weather widget to Flarum
统计信息
- 总下载量: 24
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2019-09-26