I'm just about brand new to writing in Razor, and equally new to Umbraco. Before this, I've only worked in php based cms's before this, so some habits need to be broken. Also, some things just need to be relearned.
So far, Umbraco is really great, love the community here, love the system. I've managed to have the majority of my questions answered through searches, but I'm hung up on this one.
I'm making a piece of code where users can enter an rss feed and have it output the feed into a page. It works great, except the timestamp is displaying the rss default time, which is not terribly user friendly.
Here's the code thus far:
<div class="rssFeed">
@using System.Xml.XPath;
@using System.Xml;
@{
XmlTextReader udBrudRSS = new XmlTextReader(RssFeedDrillDown);
XmlDocument doc = new XmlDocument();
doc.Load(udBrudRSS);
XmlNodeList rssItems = doc.SelectNodes("//item");
}
<ul class="rssFeed">
@{
//For each item node we can then ouput what we want
int someLinkCount = Int32.Parse(Model.GetElementValue("FeedItems"));
var i =0;
foreach (XmlNode node in rssItems)
{
<li class="rssFeedItem">
<div class="rssTitle"><a href="@node["link"].InnerText">@node["title"].InnerText</a></div>
<div class="rssDate">@node["pubDate"].InnerText</div>
<p class="rssMessage">@Html.Raw(@node["description"].InnerText)</p>
</li>
i++;
if (i == @someLinkCount){ break; }
}
}
</ul>
<!-- /content -->
</div>
I've found the following snippet, which seems to answer the question i have:
Formatting pubdate node from rss feed
Hey everyone,
I'm just about brand new to writing in Razor, and equally new to Umbraco. Before this, I've only worked in php based cms's before this, so some habits need to be broken. Also, some things just need to be relearned.
So far, Umbraco is really great, love the community here, love the system. I've managed to have the majority of my questions answered through searches, but I'm hung up on this one.
I'm making a piece of code where users can enter an rss feed and have it output the feed into a page. It works great, except the timestamp is displaying the rss default time, which is not terribly user friendly.
Here's the code thus far:
I've found the following snippet, which seems to answer the question i have:
But I'm having trouble bridging the two pieces of code!
Any insight is greatly appreciated
Hi Jonny and welcome to Our!
I think you need something like this:
Or in your specific code:
You find info on the various default formats here or custom ones here
Jeavon
Brilliant! Thank you so much. I think I was overcomplicating the matter.
You're welcome!
I'm happy to have posted a solution using the Razor string conversion helper methods (AsDateTime) that I only recently discovered myself :-)
is working on a reply...