astina/social-links-bundle
最新稳定版本:2.3.0
Composer 安装命令:
composer require astina/social-links-bundle
包简介
Symfony bundle that is using SocialLinks to generate share links for social networks.
README 文档
README
AstinaSocialLinksBundle is basically a wrapper around oscarotero/social-links. Its main purpose is to generate social links based on given provider.
Currently supported providers.
Install
Step 1: Add to composer.json
"require" : { // ... "astina/social-links-bundle":"dev-master", }
Step 2: Enable the bundle
Enable the bundle in the kernel:
<?php // app/AppKernel.php public function registerBundles() { $bundles = array( // ... new Astina\Bundle\SocialLinksBundle\AstinaSocialLinksBundle(), ); }
Usage
Main functionality of this bundle is to generate a social link for given provider and url. It can be used as an twig extension, like in the example below.
Basic usage:
{{ social_link('facebook') }}
Extended usage:
{{ social_link('facebook', 'http://www.astina.ch', {'text': 'Custom text', attributes: {'class': 'custom-share', 'target': '_self'} }, 'Custom link text') }}
This example will return an HTML response which looks like.
<a href="https://www.facebook.com/sharer.php?s=100&p%5Burl%5D=http%3A%2F%2Fwww.astina.ch" class="custom-share" target="_self"></a>
Helper accepts three parameters - provider as string, url as string, options as multidimensional array and link text as string. There you can basically add as many custom attributes as you want.
Options and default values:
'title' => null 'text' => null 'options' => array('attributes' => array('target' => '_blank')) 'linkText => null
Template extending
It is also possible to extend a social link template, by simply adding a socialLink.html.twig template in app/Resources/AstinaSocialLinksBundle/views/SocialLinks.
Run tests
bin/phpunit
统计信息
- 总下载量: 47.08k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 12
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2014-10-24