linusrendahl / social-fontawesome
用于生成带 FontAwesome 图标的社交链接的 PHP 类。
1.0.2
2014-12-15 23:00 UTC
Requires
- php: >=5.4
This package is not auto-updated.
Last update: 2024-09-24 00:44:59 UTC
README
用于生成带 FontAwesome 图标的社交链接的 PHP 类。
##注意:此模块不会将 FontAwesome 添加到您的项目中。您需要自己添加。
##安装:要么下载,要么使用 composer
"require": { "linusrendahl/social-fontawesome": "1.*" }
##基本用法:用法
//create the object $icons = new LinusRendahl\SocialFontAwesome; //add some icons with the add method $icons ->add('https://#') ->add('http://twitter.com') ->add('http://instagram.com'); //get the html $html = $icons->getHtml();
返回值:
<a href="https://#"title="Facebook"> <i class="fa fa-facebook"></i> </a> <a href="http://twitter.com"title="Twitter"> <i class="fa fa-twitter"></i> </a> <a href="http://instagram.com"title="Instagram"> <i class="fa fa-instagram"></i> </a>
##默认支持的图标和社交网络
- GitHub
- YouTube
- Tumblr
- Vimeo
##方法
->add('http://facebook.com/user')
返回值:
<a href="http://facebook.com/user" title="Facebook"> <i class="fa fa-facebook"></i> </a>
####add:使用此方法将您的 URL 添加到您在默认列表中指定的社交网络。仅当社交网络在默认列表中时使用。
//addCustom($url, $class, $title=null) ->addCustom('http://some-other-network.com/user', 'fa fa-some-icon', 'My title!')
返回值:
<a href="http://some-other-network.com/user" title="My title!"> <i class="fa fa-some-icon"></i> </a>
####addCustom:如果您的链接不在支持的默认列表中,请使用此方法创建自己的链接。
->add('http://facebook.com/user')->title('Welcome to my Facebook page!')
返回值:
<a href="http://facebook.com/user" title="Welcome to my Facebook page!"> <i class="fa fa-facebook"></i> </a>
####title:使用此方法更改默认图标的标题。
->add('http://facebook.com/user')->wrapper('<div class="wrapper">', '</div>')
返回值:
<div class="wrapper"> <a href="http://facebook.com/user" title="Facebook"> <i class="fa fa-facebook"></i> </a> </div>
####wrapper:使用此方法添加一个 HTML 元素来包裹图标。
->add('http://facebook.com/user')->setClass('foobar')
返回值:
<a href="http://facebook.com/user" title="Facebook"> <i class="fa fa-facebook foobar"></i> </a>
####wrapper:使用此方法添加一个 HTML 元素来包裹图标。
->add('http://facebook.com/user')->setClass('foobar')
返回值:
<a href="http://facebook.com/user" title="Facebook"> <i class="fa fa-facebook foobar"></i> </a>
####setClass:使用此方法为 i 元素添加一个自定义类。
->getHtml()
####getHtml:这是一个返回格式化 HTML 的方法。
->getArray()
####getArray:这是一个返回原始图标数组的的方法,您可以使用自己的标记轻松格式化。
//create the object $icons = new LinusRendahl\SocialFontAwesome; //add some icons with the add method $icons ->add('https://#') ->add('http://twitter.com')->title('My Twitter Page!') ->add('http://instagram.com')->title('Cool pictures!')->setClass('foobar') ->wrapper('<div class="wrapper">', '</div>'); //get the html $html = $icons->getHtml(); echo $html;
返回值:
<div class="wrapper"> <a href="https://#" title="Facebook"> <i class="fa fa-facebook"></i> </a> <a href="http://twitter.com" title="My Twitter Page!"> <i class="fa fa-twitter"></i> </a> <a href="http://instagram.com" title="Cool pictures!"> <i class="fa fa-facebook foobar"></i> </a> </div>
##完整示例用法
- ##历史记录
####v1.0.2
- 已作为 composer 包添加到 Packagist。