+1-888-365-2779
Try Now
More in this section

Forums / Developing with Sitefinity / Get the full URL for a NewsItem?

Get the full URL for a NewsItem?

2 posts, 0 answered
  1. Nick
    Nick avatar
    15 posts
    Registered:
    30 Oct 2013
    17 Dec 2013
    Link to this post
    I'm trying to create an MVC widget to list news items, so far this is working well.  Just stuck on one thing: how can I get the full default URL to a given news item, based on the default priority page I've set under "Pages where NewsItem items are published"?

    Currently I'm attempting to do this by getting the DefaultPageId for the NewsItem and then using that page id to get the page node and from there the full url using the GetFullUrl() method.  It's when I try to access the DefaultPageId for the NewsItem I get an error:

    The multi-part identifier "b.default_page_id" could not be bound.
    Statement(s) could not be prepared.

    This is my code so far:

    var newsItems = App.WorkWith().NewsItems().Get();
    var defaultPage = newsItems.FirstOrDefault().DefaultPageId;

    Any ideas?
  2. Ferdi Nebiev
    Ferdi Nebiev avatar
    7 posts
    Registered:
    01 Aug 2016
    19 Dec 2013
    Link to this post
    Hello Nick,

    Thank you for contacting Telerik Support.

    There is an easy way to get newsItem's full URL :

    SystemManager.GetContentLocationService().GetItemDefaultLocation(newsItem)
    .ItemAbsoluteUrl

     You need to add using Telerik.Sitefinity.Services.

    I believe this will help you achieve your goal.

    Regards,
    Ferdi Nebiev
    Telerik
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested 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