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

Forums / Developing with Sitefinity / Loading News using NewsManager

Loading News using NewsManager

4 posts, 1 answered
  1. Fernando
    Fernando avatar
    31 posts
    Registered:
    08 Jun 2009
    07 Feb 2011
    Link to this post
    Hi,

    I have a control that loads the news items with a Telerik.News.NewsManager using the item's GUID that comes from the URL.

    I know this is not the best way to do that, but it's already implemented. And it works, unless we have some image inside the content of the news.

    This is what I'm using to get the items:

    Telerik.News.NewsManager newsManager = new Telerik.News.NewsManager("News");
          Telerik.Cms.Engine.IContent thisContent = newsManager.Content.GetContent(contentId.Value);
     
          Telerik.Cms.Engine.Data.CmsContentBase myBase = (Telerik.Cms.Engine.Data.CmsContentBase)thisContent;
     
          if (myBase != null)
          {
              lblNewsTitle.Text = myBase.GetMetaData("Title").ToString();
              lblNewsDate.Text = ((DateTime)myBase.GetMetaData(newsManager.PublicationDateField)).ToString("dd MMM yy");
              lblContent.Text = myBase.Content.ToString();
          }

    contentId is a nullable Guid.

    All I use is the Title, Publication Date and the Content. The problem is when I have an image in the content. Instead of having a url on the src of the tag <img>, what I have is something like this:

    <img src="[Libraries]00000000-0000-0000-0000-000000000000" alt="whatever" />

    Is that what really should happen when we access the news using the News Manager? Is there something that I can use from sitefinity to easily get the url of these images?

    Thanks
    Fernando Melo
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    07 Feb 2011
    Link to this post
    Hello Fernando,

    Generally you should use LinkParser.ResolveLinks to resolve all dynamic links that are added to your content item.

    Best wishes,
    Ivan Dimitrov
    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
    Answered
  3. Fernando
    Fernando avatar
    31 posts
    Registered:
    08 Jun 2009
    07 Feb 2011
    Link to this post
    Thanks, I think this is what I'm looking for... but, what should I pass as parameter?
    only the sfref? ("[Libraries]00000000-0000-0000-0000-000000000000")
    the img tag? ("<img src="[Libraries]00000000-0000-0000-0000-000000000000" alt="whatever" />")
    or my whole content?

    I tried some ways here, but or they didn't work and it returned exactly what I passed or they returned this error:

    No default implementation for retrieving item URL yet. Please use delegate to handle retrieval.

    with this stack trace:
    [NotImplementedException: No default implementation for retrieving item URL yet. Please use delegate to handle retrieval.]
       Telerik.Cms.Web.LinkParser.Resolve(HtmlChunk chunk, Int32 valueIndex, GetItemUrl itemUrl, ResolveUrl resolveUrl, Boolean preserveOriginalValue, Boolean resolveAbsolute) +924
       Telerik.Cms.Web.LinkParser.ParseHtml(String html, GetItemUrl itemUrl, ResolveUrl resolveUrl, Boolean resolve, Boolean preserveOriginalValue, Boolean resolveAbsolute) +342
       Telerik.Cms.Web.LinkParser.ResolveLinks(String html) +35
    
  4. Fernando
    Fernando avatar
    31 posts
    Registered:
    08 Jun 2009
    07 Feb 2011
    Link to this post
    There was one parameter thar seemed optional, but it wasn't...

    I had to pass a delegate GetItemUrl(string providerName, Guid id, bool resolveAsAbsoluteUrl)
Register for webinar
4 posts, 1 answered