合并脚本和样式表
is a website created by myself and 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.
是一个由我本人和创建的网站,博客作者和开发人员都提交有关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)
is an outstanding feed reading PHP library which we'll use to grab, read, and cache the Script & Style feed. to hit the SimplePie download page.
是一个出色的feed阅读PHP库,我们将使用它来抓取,读取和缓存Script&Style feed。 访问SimplePie下载页面。
步骤2:PHP代码 (Step 2: The PHP Code)
//get teh simplepie libraryrequire_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 itemforeach ($items as $item){ echo '',$item->get_title(),'';}
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, , and Chris Coyier's website, .
提供SimplePie后,请插入“脚本和样式”提要。 您会注意到,您想要启用缓存并提供一个缓存文件夹以保持站点高效。 将每个项目放入$ items数组后,只需输出XHTML,您将最终编写脚本和样式。 您可以在我的网站和Chris Coyier的网站上看到示例。
就这样! (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。 有趣的样式您的脚本和样式的站点提要。 完成后,将链接发布到您的网站-我们很乐意看到您创建的内容!
翻译自:
合并脚本和样式表