创建RSS提要与PHP脂肪免费框架


Create RSS feed with PHP Fat Free Framework?

我正在寻找一种使用Fat Free Framework从数据库查询创建RSS提要的方法。

F3是否打包了这个功能?或者是否有任何方法可以使用F3模板创建RSS提要?

是的,您可以使用f3模板引擎来输出正确的xml,例如:

rss.template:

<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
<channel>
    <title>{{@blog.title}} </title>
    <link>{{@REALM}}</link>
    <description></description>
    <lastBuildDate>{{date(@blog.date.rss)}}</lastBuildDate>
    <language>{{@LANGUAGE}}</language>
    <atom:link href="{{@REALM}}" rel="self" type="application/rss+xml" />
    <repeat group="{{@posts}}" key="{{@key}}" value="{{@post}}">
    <item>
        <title>{{@post->title}} </title>
        <pubDate>{{date(@blog.date.rss, @post->date->sec)}}</pubDate>
        <link>http://studio{{@BASE}}/post/{{@post->_id}}/{{tools::slug(@post->title)}}</link>
        <guid>http://studio{{@BASE}}/post/{{@post->_id}}</guid>  
        <description><![CDATA[ {{substr(strip_tags(@post->content),0,256)}} ]]></description>
    </item>
    </repeat>
</channel>
</rss>