drmonkeyninja/cakephp-social-share
Composer 安装命令:
composer require drmonkeyninja/cakephp-social-share
包简介
CakePHP helper for creating social share/bookmark links
README 文档
README
This plugin provides a CakePHP View helper for creating links to share content on numerous social networks and bookmarking sites.
The aim of the plugin is to keep things simple. It doesn't come packaged with any JavaScript and I leave design decisions up to you. You can choose whether you want to use text, images, sprites or an icon font for your links.
Social Share currently supports Delicious, Digg, Evernote, Facebook, Friend Feed, Google Bookmarks, Google+, LinkedIn, Newsvine, Pinterest, Pocket, Reddit Slashdot, simple email, StumbleUpon, Technorati, Tumblr, Twitter and WhatsApp.
Note: This branch is for CakePHP 4.x.
Installation
Install using composer: composer require drmonkeyninja/cakephp-social-share:4.*
Then add the following line to your Application.php file to load the plugin.
$this->addPlugin(\SocialShare\Plugin::class);
Also don't forget to add the helper in your AppView:-
$this->loadHelper('SocialShare.SocialShare');
Usage
SocialShareHelper::link()
SocialShareHelper::link(string $service, string $title, mixed $url = null, array $options = [])
Returns an HTML link to share the current page for the supplied service. For example to create a link for Facebook:-
echo $this->SocialShare->link( 'facebook', __('Share on Facebook') );
You can easily produce a list of links to share to different social networks:-
$services = [ 'facebook' => __('Share on Facebook'), 'gplus' => __('Share on Google+'), 'linkedin' => __('Share on LinkedIn'), 'twitter' => __('Share on Twitter') ]; echo '<ul>'; foreach ($services as $service => $linkText) { echo '<li>' . $this->SocialShare->link( $service, $linkText ) . '</li>'; } echo '</ul>';
Supported services:-
- delicious
- digg
- evernote
- friendfeed
- google (Google Bookmarks)
- gplus (Google+)
- newsvine
- slashdot
- stumbleupon
- technorati
- tumblr
You can pass a URL or a routing array as the third parameter for the URL you want to share.
$options supports the same options as HtmlHelper::link() as well as a 'text' option for a page title you want to include when sharing the URL.
For Pinterest there is an additional 'image' option for a URL to an image to share.
SocialShareHelper::href()
SocialShareHelper::href(string $service, mixed $url = null, array $options = [])
Returns an URL for sharing to the supplied service.
SocialShareHelper::fa()
SocialShareHelper::fa(string $service, mixed $url = null, array $options = [])
Returns an HTML link just like SocialShare::link() except the link text will be a relevant Font Awesome icon for the service.
For example:-
echo $this->SocialShare->fa( 'facebook', 'http://example.com' );
Will output:-
<a href="https://www.facebook.com/sharer/sharer.php?u=http%3A%2F%2Fexample.com"> <i class="fa fa-facebook"></i> </a>
If you need to change the icon markup output by fa() you can override the icon class using icon_class:-
echo $this->SocialShare->fa( 'facebook', null, ['icon_class' => 'fa fa-facebook-square'] );
drmonkeyninja/cakephp-social-share 适用场景与选型建议
drmonkeyninja/cakephp-social-share 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 103.66k 次下载、GitHub Stars 达 31, 最近一次更新时间为 2015 年 03 月 01 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「cakephp」 「helper」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 drmonkeyninja/cakephp-social-share 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 drmonkeyninja/cakephp-social-share 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 drmonkeyninja/cakephp-social-share 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
CakePHP 4.x AdminLTE Theme.
Datetime helpers for timezone handling
Library with classes to help you do batch.
This adds functions about array. If you feel like there few php built-in functions about array, this will be useful.
HTML and form generation
Email Toolkit Plugin for CakePHP
统计信息
- 总下载量: 103.66k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 34
- 点击次数: 3
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2015-03-01