Setting ServiceProvider for BlogsManager CRUD
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
For anybody who is looking. I managed to solve this.
knowledgebase.progress.com/.../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);