Custom New Rotator
I have built a custom news rotator that lists the top 5 news items and displays an image, which is a custom field, the title, summary, and a "read more" link for each. I have also created a page where I have dropped the built-in news list widget onto. The read more link links to the news page i created, I am having problems generating that link. I have used both DateCreated and PublicationDate and it works, but when a news item gets modified that link does not work. Any suggestions?
Here is the basis for how I am implementing this:
var topNews = App.WorkWith().NewsItems()
.Where(t => t.Status == ContentLifecycleStatus.Live)
.OrderByDescending(o => o.PublicationDate)
.Get()
.ToList();
foreach (var item in topNews)
this.items.InnerHtml += "<
br
/><
a
href=\"/exclusive-news/" + String.Format("0:yyyy/MM/dd", item.PublicationDate) + "/" + item.UrlName + "\"><
img
src=\"/Images/ui/news-read-more-link.png\" /></
a
></
p
></
div
>" + Environment.NewLine;
Hi Alex,
Thank you for contacting Telerik Support.
Can you try forming the link to your news page by using the urls from Urls collection of your news items. Bellow is some sample code how you can extract urls:
var url = App.WorkWith().NewsItems().Where(nI => nI.Title == "Some title").First().GetLive().Get().Urls.First().Url;