More in this section

Forums / General Discussions / Custom New Rotator

Custom New Rotator

2 posts, 0 answered
  1. Alex
    Alex avatar
    39 posts
    Registered:
    19 Jul 2010
    03 Feb 2011
    Link to this post
    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
  2. Radoslav Georgiev
    Radoslav Georgiev avatar
    3370 posts
    Registered:
    01 Feb 2016
    05 Feb 2011
    Link to this post
    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
2 posts, 0 answered