Symfony 2 数据未在 RSS.XML 文件中呈现,但数据存在于标记代码中

发布于 2024-12-02 22:32:28 字数 1351 浏览 1 评论 0原文

我正在为我的项目创建一个 RSS 提要,当前保存 RSS 数据的文件(XML 文件)如下所示:

<?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>
    {% for latestnews in news %}
    <item> 
        <title>{{ latestnews.title }}</title>  
        <description>{{ latestnews.content | truncate(500) | raw }}</description>  
        <link>../app_dev.php{{latestnews.url }}</link>  
        <guid isPermaLink="false">{{latestnews.url }}</guid>
        <pubDate>{{ latestnews.lastedit | date('jS F Y') }}</pubDate>  
        <media:thumbnail width="144" height="81" url="{{ latestnews.mainImage }}"/> 
    </item>  
    {% endfor %}
 </channel> 
</rss> 

但是,当在浏览器中查看页面时,除了 < 中包含的数据和标签之外的所有内容都会显示出来 。显示 code>{% forlatestnews in news %} 和 {% endfor %}。不显示实际的最新新闻文章。然而,当我检查标记代码时,会显示最新的新闻文章。

我查看过其他 RSS 提要(例如 BBC 新闻),我看不出我所做的与他们所做的有任何区别。我是否必须添加一些特定的 Symfony 代码,使其在循环内时渲染项目?

干杯

I am creating an RSS feed for my project, and currently the file that holds the RSS data (the XML file) is like this:

<?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>
    {% for latestnews in news %}
    <item> 
        <title>{{ latestnews.title }}</title>  
        <description>{{ latestnews.content | truncate(500) | raw }}</description>  
        <link>../app_dev.php{{latestnews.url }}</link>  
        <guid isPermaLink="false">{{latestnews.url }}</guid>
        <pubDate>{{ latestnews.lastedit | date('jS F Y') }}</pubDate>  
        <media:thumbnail width="144" height="81" url="{{ latestnews.mainImage }}"/> 
    </item>  
    {% endfor %}
 </channel> 
</rss> 

However, when the page is viewed in the browser, everything except for the data and tags contained within the {% for latestnews in news %} and {% endfor %} displays. The actual latest news articles don't display. When I check the mark up code however, the latest news articles are displayed.

I've looked at other RSS feeds (such as the BBC News one) and I can't see any difference in what I've done to what they've done. Do I have to add something, a specific Symfony code, that makes it render items when it's inside a loop?

Cheers

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

旧竹 2024-12-09 22:32:28

该问题源于使用 标记。一旦删除,所有文章都会正确显示。奇怪的是,是Internet Explorer帮我解决了这个问题!

The problem stemmed from using the <media:thumbnail> tag. Once this was removed all of the articles displayed properly. Bizarrely, it was Internet Explorer that helped me solve it!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文