More in this section
Forums / General Discussions / Setting ServiceProvider for BlogsManager CRUD

Setting ServiceProvider for BlogsManager CRUD

The forums are in read-only mode. In case that you want to directly contact the Progress Sitefinity team use the support center. In our Google Plus group you can find more than one thousand Sitefinity developers discussing different topics. For the Stack Overflow threads don’t forget to use the “Sitefinity” tag.
2 posts, 1 answered
  1. eduard
    eduard avatar
    1 posts
    Registered:
    19 May 2016
    10 Mar 2017
    Link to this post

    Hello all,

    I am trying to query blog posts using CRUD, I have managed to get the basic search done.

    The problem that I am facing is that I have multiple service providers for my blogs (I have a custom service provider from here). When I ask for my blogs I only get blogs from the default provider, but I only want blogs from from the custom provider. 

    Code:

    BlogsManager blogsManager = BlogsManager.GetManager();
    List<BlogPost> blogPosblogsManagert = blogsManager.GetBlogPosts().Where(b => b.Status == ContentLifecycleStatus.Live).ToList();

    I am able to find the provider(s) inside the blog manager, but I don't understand how to set it. (blogsManager.Provider / blogsManager.AllProviders)

    Thank you,
    Eduard

  2. eduard
    eduard avatar
    1 posts
    Registered:
    19 May 2016
    27 Jun 2017 in reply to eduard
    Link to this post

    For anybody who is looking. I managed to solve this. 

    http://knowledgebase.progress.com/articles/Article/how-to-get-dynamic-content-items-from-all-types-and-providers-via-api

    Code:

    var providers = BlogsManager.GetManager().GetContextProviders();
    BlogsManager blogManager;
    var blogs = new List<Telerik.Sitefinity.Blogs.Model.BlogPost>();
     
    foreach (var provider in providers)
    {
         if (provider.Name == "UrlNameProvider")
         {
             blogManager = BlogsManager.GetManager(provider.Name);
             var tempList = blogManager.GetItems(typeof(Telerik.Sitefinity.Blogs.Model.BlogPost), string.Empty, string.Empty, 0, 0)
                 .OfType<Telerik.Sitefinity.Blogs.Model.BlogPost>()
                 .Where(i => i.Status == ContentLifecycleStatus.Live && i.Visible == true).ToList();
                 blogs.AddRange(tempList);
         }
    }

     

    Answered
2 posts, 1 answered