在 Symfony 中创建 RSS 提要 [英] Creating a rss feed in Symfony

查看:42
本文介绍了在 Symfony 中创建 RSS 提要的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在 Symfony 中创建一个 RSS 提要.

I'm trying to create a RSS feed in Symfony.

我添加了以下路线:

rss_every_content:
  url:    /rss/all
  param: { module: content, action: index, sf_format: rss }
  requirements:
    sf_method: [get]

然后我在 module/content/templates/中创建了一个名为 indexSuccess.rss.php 的文件:

And I created a file called indexSuccess.rss.php in module/content/templates/ :

test message

但是当我转到 url mysite/rss 时,我得到的只是一个空白页面!根本没有内容,甚至没有调试工具栏...帮助!这是怎么回事?

But when I go to the url mysite/rss, all I get is an empty page ! No content at all, not even the debug toolbar... Help ! What is going on ?

推荐答案

我遇到了和你一样的问题.我注意到 sf_format: xmlindexSuccess.xml.php 似乎可以工作,只要您在顶部指定 RSS XML 标记,例如:

I had the same problem as you. I noticed that sf_format: xml with indexSuccess.xml.php seems to work as long as you specify the RSS XML tag at the top like:

<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0">

<channel>
    <title>RSS Example</title>
    <description>This is an example of an RSS feed</description>
    <link>http://www.domain.com/link.htm</link>
    <lastBuildDate>Mon, 28 Aug 2006 11:12:55 -0400 </lastBuildDate>
    <pubDate>Tue, 29 Aug 2006 09:00:00 -0400</pubDate>

    <item>
        <title>Item Example</title>
        <description>This is an example of an Item</description>
        <link>http://www.domain.com/link.htm</link>
        <guid isPermaLink="false">1102345</guid>
        <pubDate>Tue, 29 Aug 2006 09:00:00 -0400</pubDate>
    </item>

</channel>
</rss>

来自 http://www.rss-tools.com/rss-example.htm

这是一个黑客,但我不知道还能怎么做.

It's a hack but I can't see how else to do it.

这篇关于在 Symfony 中创建 RSS 提要的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆