合并脚本和样式表_将脚本和样式供稿添加到您的网站

合并脚本和样式表

Script & Style

Script & Style is a website created by myself and Chris Coyier where bloggers and developers alike submit articles about CSS, XHTML, jQuery, MooTools, and other website design and development topics. The site's popularity continues to grow due the community's enthusiasm and number of quality articles submitted on a daily basis.

Script&Style是一个由我本人和Chris Coyier创建的网站,博客作者和开发人员都提交有关CSS,XHTML,jQuery,MooTools以及其他网站设计和开发主题的文章。 由于社区的热情和每天提交的高质量文章的数量,该网站的受欢迎程度持续增长。

I love to share knowledge on my website and the first thing I did when we got the site going was get the feed on my site so that I could share links to other quality articles. The process took only 5 minutes. Here's how you can add the Script & Style feed to your website!

我喜欢在我的网站上分享知识,而当我们开始运行该网站时,我要做的第一件事就是在我的网站上获取供稿,以便我可以共享其他高质量文章的链接。 该过程仅花费了5分钟。 您可以通过以下方法将脚本和样式供稿添加到您的网站!

步骤1:下载SimplePie (Step 1: Download SimplePie)

SimplePie is an outstanding feed reading PHP library which we'll use to grab, read, and cache the Script & Style feed. Click here to hit the SimplePie download page.

SimplePie是一个出色的feed阅读PHP库,我们将使用它来抓取,读取和缓存Script&Style feed。 单击此处访问SimplePie下载页面。

步骤2:PHP代码 (Step 2: The PHP Code)


//get teh simplepie library
require_once('simplepie/simplepie.inc');

//grab the feed
$feed = new SimplePie('http://feeds.feedburner.com/ScriptAndStyle');

//enable caching
$feed->enable_cache(true);

//provide the caching folder
$feed->set_cache_location($_SERVER['DOCUMENT_ROOT'].'/cache');

//set the amount of seconds you want to cache the feed
$feed->set_cache_duration(1800);

//init the process
$feed->init();

//let simplepie handle the content type (atom, RSS...)
$feed->handle_content_type();

//load my own array -- i like my own arrays...
for ($x = 0; $x < $feed->get_item_quantity(15); $x++) { $items[] = $feed->get_item($x); }

//loop through each item
foreach ($items as $item)
{
	echo '<a href="',$item->get_link(),'" class="sns-link">',$item->get_title(),'</a>';
}


David Walsh Script & Style feed

Once you have SimplePie available, pull in the Script & Style feed. You'll note that you want to enable caching and provide a caching folder to keep your site efficient. Once you've gotten each item into an $items array, you simply output the XHTML which you will eventually script and style. You can see examples on my site, davidwalsh.name, and Chris Coyier's website, CSS-Tricks.com.

提供SimplePie后,请插入“脚本和样式”提要。 您会注意到,您想要启用缓存并提供一个缓存文件夹以保持站点高效。 将每个项目放入$ items数组后,只需输出XHTML,您将最终编写脚本和样式。 您可以在我的网站davidwalsh.name和Chris Coyier的网站CSS-Tricks.com上看到示例。

就这样! (That's All!)

Adding the Script & Style feed to your website is a piece of cake! Well, thanks to SimplePie, it's a piece of pie. Have fun styling your Script & Style site feed. Post a link to your website when you're done -- we'd love to see what you've created!

将脚本和样式供稿添加到您的网站真是小菜一碟! 好吧,这要归功于SimplePie。 有趣的样式您的脚本和样式的站点提要。 完成后,将链接发布到您的网站-我们很乐意看到您创建的内容!

翻译自: https://davidwalsh.name/script-style-feed

合并脚本和样式表

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值