Custom New Rotator

Posted by Community Admin on 03-Aug-2018 18:03

Custom New Rotator

All Replies

Posted by Community Admin on 03-Feb-2011 00:00

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;
            

Thanks,
Alex Lorenz

Posted by Community Admin on 05-Feb-2011 00:00

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;

Best wishes,
Radoslav Georgiev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items

This thread is closed