Hi, I'm trying to produce an rss feed of the news item on our website but it isn't working.The page just doesn't load when I apply the RSS template to my URL.
I followed the video tutorial but must be missing something...
This is the code in my rss.cshtml file:
@using umbraco.MacroEngines @inherits DynamicNodeContext @{ //Change mime type umbraco.library.ChangeContentType("text/xml");
//Get the domain var siteURL = "http://" + Request.Url.Host;
//Get the news area node (only one of these per site) var newsAreaNode = Model.Newslists.First();
//Get the latest createDate of all news items to use as the RSS feed updateDate var RSSFeedPubDate = newsAreaNode.Children.Where("Visible").OrderBy("NewsDate desc").First(); } <?xml version="1.0" encoding="UTF-8"?> <rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rssdatehelper="urn:rssdatehelper"> <channel> <title>News rss</title> <pubDate>@RSSFeedPubDate.UpdateDate.ToString("r")</pubDate> <generator>umbraco</generator> <description>Add your description here</description> <language>en</language> @{ foreach (var item in newsAreaNode.Children.Where("Visible")) { <item> <title>@item.Name</title> <pubDate>@item.UpdateDate.ToString("r")</pubDate> <guid>@item.Url</guid> <content:encoded><![CDATA[@item.Summary]]></content:encoded> </item> } } </channel> </rss>
Comment out sections of code and see if you can isolate whats going it. Infact first thing id try is comment the lot out and just put a h1 saying test in the rss macro file to prove its getting called and then add bits back in.
Not yet I'm afraid although I think it is the <pubDate> that is causing it to loop and do nothing. When I remove that line from under <channel> the page at least loads...
hi again, I'm now getting this error on the page after it loads:
XML Parsing Error: XML or text declaration not at start of entity Location: http://www.regents.ac.uk/rss Line Number 2, Column 1:<?xml version="1.0" encoding="UTF-8"?> ^
This is my latest .cshtml (for now I'm leaving out the <pubDate> from under channel
Make sure in your template / masterpage that you call the macro right after the content area declaration (i,e don't put a carriage return in or anything)
so right after the %><umbraco:Macro in a masterpage or right after the @{}@Umbraco.Macro
Thanks very much Damian that was it! I now have an rss feed working except for the pubdate field. If I remove this field from everything it works fine but when I add it in anywhere I get the original looping problem. This is my current cshtml:
RSS feed not working
Hi, I'm trying to produce an rss feed of the news item on our website but it isn't working.The page just doesn't load when I apply the RSS template to my URL.
I followed the video tutorial but must be missing something...
This is the code in my rss.cshtml file:
and this is the code in the rss template file:
What do you get? A blank page or an error?
The page just doesn't load... it's here if that helps: http://regents.ac.uk/rss
thanks
Seems to be looping and then doing nothing.
Comment out sections of code and see if you can isolate whats going it. Infact first thing id try is comment the lot out and just put a h1 saying test in the rss macro file to prove its getting called and then add bits back in.
Thanks for the tip Damian, I'll try it
Any luck?
Not yet I'm afraid although I think it is the <pubDate> that is causing it to loop and do nothing. When I remove that line from under <channel> the page at least loads...
hi again, I'm now getting this error on the page after it loads:
This is my latest .cshtml (for now I'm leaving out the <pubDate> from under channel
Make sure in your template / masterpage that you call the macro right after the content area declaration (i,e don't put a carriage return in or anything)
so right after the %><umbraco:Macro in a masterpage or right after the @{}@Umbraco.Macro
You understand what i mean?
Thanks for getting back to me Daminan. There aren't any breaks in my template, it's just:
Hi Clare
Could you try to exclude <?xml version="1.0" encoding="UTF-8"?> from your rss.cshtml file and place it here:
I think I had an issue once, where it worked when I placed the xml declaration directly in the template instead..
/Bjarne
Thanks for the suggestion Bjarne, unfortunately I just got a server error when I tried that.
What about in the macro code itself?
Make sure your xml declaration is the first line in the code file.
Move the xml declaration above this line so it is rifght at the top:
Thanks very much Damian that was it! I now have an rss feed working except for the pubdate field. If I remove this field from everything it works fine but when I add it in anywhere I get the original looping problem. This is my current cshtml:
The thing id try next is to add pubdate but just type some text in.
If that works then look at the actual data thats going in the field. It may have some characters xml doesnt like.
I have this in my feed but look ssimilar to yours:
is working on a reply...