get correct url for news items
How can I get the correct url for the news items? I'm trying to load my datalist that I created and I'm able to get the news title, status, etc but not the correct url. The 'out of the box' news module has the URL as /year/month/date/newstitle, in my datalist I'm showing /appname/home/template/newstitle
what field do I need to show to get the correct URL for my news item?
here is my code, is this not the correct code?
public
IQueryable<NewsItem> GetAllNews()
NewsManager manager = NewsManager.GetManager();
IQueryable<NewsItem> allNews = manager.GetNewsItems()
.Where(n => n.Status == ContentLifecycleStatus.Live);
return
allNews;
Hi CsharpGuy,
You need to get the UrlData
var test = App.WorkWith().NewsItem().Get().Urls.Where(u => u.RedirectToDefault == false);
Note that the entire url is formatted based on the page on which you should have NewsView widget. The url that will be returned by the code above does not exist as site map node.
Best wishes,
Ivan Dimitrov
the Telerik team
I am getting a NullReferenceException on
App.WorkWith().NewsItem().Get()
Hello Bruno ,
Get a single new item in Master status
var test = App.WorkWith().NewsItems().Where(ni => ni.Status == ContentLifecycleStatus.Master).First().Get().Urls.Where(u => u.RedirectToDefault == false);
Best wishes,
Ivan Dimitrov
the Telerik team