More in this section

Forums / Developing with Sitefinity / Get News or Document by URL

Get News or Document by URL

6 posts, 1 answered
  1. marco pessina
    marco pessina avatar
    16 posts
    Registered:
    02 Nov 2009
    20 Jan 2010
    Link to this post
    Hi,
    we are using the method Cms.Engine.ContentManager.Providers.GetContent(string Url) to retrieve news or document items but we are always getting nothing as result.

    Dim providers As IDictionary(Of String, Cms.Engine.ContentProviderBase) = Cms.Engine.ContentManager.Providers 
    Dim dataSource As IList(Of ResultItem) = SearchManager.Search(searchQuery, Me.IndexCatalogue, 0, 0, Me.WordsMode, Me.EscapeSpecialChars, totalItems) 
     
    For Each item As ResultItem In dataSource 
        For Each provider As Telerik.Cms.Engine.Data.Providers.DefaultProvider In providers.Values 
            cnt = provider.GetContent(item.Url) 
            ' Etc... 
        Next 
    Next 

    How can we correctly use this method?
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    20 Jan 2010
    Link to this post
    Hello marco pessina,

    Please take a look a this API article - Finding Content Items. You have to work with IContent interface and Telerik.Cms.Engine.ContentManager class. Currently you are using the Data class with is used internally only by the data provider.

    Best wishes,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  3. marco pessina
    marco pessina avatar
    16 posts
    Registered:
    02 Nov 2009
    20 Jan 2010
    Link to this post
    Hi,
    I will try to eplain better what i'm tryng to do:
    1 - we found a way do build a library index on documents (pdf and office) stored in Sitefinity db
    2 - when we get back search results we have only document urls and we have to filter them by tag and then we need to get the Content object.
    3 - For this reason we need to find some method getContent by url

    Do you have any suggestion?
    Thanks.
    Regards,
  4. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    20 Jan 2010
    Link to this post
    Hi marco pessina,

    Try using the code below

    ContentProviderBase provider = ContentManager.Providers["News"];
    IContent cntItem = provider.GetContent("/09-12-19/Modifiedv1");
    if (cntItem != null)
    {
     
    }

    You can also pass the IContent object Url property (cnt.Url)

    Kind regards,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  5. marco pessina
    marco pessina avatar
    16 posts
    Registered:
    02 Nov 2009
    21 Jan 2010
    Link to this post
    Thanks Ivan, It worked fine.
    Regards
  6. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    21 Jan 2010
    Link to this post
    Hi marco pessina,

    Always glad to help.

    Regards,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
    Answered
Register for webinar
6 posts, 1 answered