Created
August 23, 2014 14:12
-
-
Save sleslie321/5d2e11520f45b5611f1d to your computer and use it in GitHub Desktop.
Create RSS Feed from Document Type in Umbraco using Razor
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@inherits Umbraco.Web.Macros.PartialViewMacroPage | |
@{umbraco.library.ChangeContentType("text/xml"); | |
var siteURL = "http://" + Request.Url.Host; | |
var HomePage = CurrentPage.AncestorOrSelf(1); | |
var RSSFeedPubDate = HomePage.Descendants("PressRelease").OrderBy("publishedDate 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>Press Releases</title> | |
<link>@siteURL</link> | |
<pubDate>@RSSFeedPubDate.UpdateDate.ToString("r")</pubDate> | |
<generator>Umbraco</generator> | |
<description>Latest Press Releases</description> | |
<language>en</language> | |
@{ | |
foreach (var release in HomePage.Descendants("PressRelease").OrderBy("publishedDate desc").Take(10)) | |
{ | |
<item> | |
<title>@release.Name</title> | |
@Html.Raw("<link>")@[email protected](release.Url)@Html.Raw("</link>") | |
<description>@release.Summary</description> | |
<pubDate>@release.publishedDate.ToString("r")</pubDate> | |
<guid>@[email protected](release.Url)</guid> | |
</item> | |
} | |
} | |
</channel> | |
</rss> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Why not write this line more simple? :)
so instead this:
or