Access to Blog Post Categories
I am looking for a way with the api to access a Blog Post Categories. I have a top level MasterPage that shows the same header and footer throughout the site. In the footer I need to show the title of the most recent blog post (which I was able to do through the API). This also needs to be a link to a details page with a url in this format:
/blog name/top category name/bottom category name/details?id=blog id.
The details page will have a blog details layout and codefile that will process the id to set the RadListView DataSource.
Is there a way to find out the category structure of a specific blog post to properly form the url?
Hello Todd,
If you have the blog post ID you can the the BlogPost object and
call blogpost.GetValue("Category") or
var propDesc = OrganizerBase.GetProperty(dataItem.GetType(), "Category") as TaxonomyPropertyDescriptor;
All the best,
Ivan Dimitrov
the Telerik team
I got the blog post using:
var manager = BlogsManager.GetManager();
var allPosts = manager.GetBlogs().Where(p => p.Title == "Broan Pro").First().BlogPosts;
var post = allPosts.Where(p=>p.Status==ContentLifecycleStatus.Live).OrderByDescending(p => p.PublicationDate).First()
but post does not have a GetValue() method. Post has a type of Telerik.Sitefinity.Blogs.Model.BlogPost
For the second way you showed I am unsure what the dataItem type should be. I tried
var propDesc = OrganizerBase.GetProperty(typeof (Telerik.Sitefinity.Blogs.Model.BlogPost), "Category") as TaxonomyPropertyDescriptor;
but I wasn't sure where to go from there. I tried to call the GetValue method with the parameter being the BlogPost that I need the categories for but this didn't seem to give what I needed.
Hi Todd,
When you use GetValue you need to pass as a parameter the property you are looking for - "Category". This should returned TrackedList of guids - the ids of the categories.
Regards,
Ivan Dimitrov
the Telerik team
Is it possible to retrieve Newsitem based on Taxonomy like the blogpost, as u mentioned here
Hi Kalyani,
You can try this approach:
Add the following using:
using
Telerik.Sitefinity.Data.Linq.Dynamic;
var catName =
"MyCategoryName"
;
var manager = TaxonomyManager.GetManager();
var categoriesTaxonomy = manager.GetTaxonomy<HierarchicalTaxonomy>(TaxonomyManager.CategoriesTaxonomyId);
var category = categoriesTaxonomy.Taxa.Where(t => t.Title == catName).FirstOrDefault();
var nm = NewsManager.GetManager();
var filteredNewsItems = nm.GetNewsItems().Where(
"Category.Contains(("
+ category.Id.ToString() +
")) && Status=\"Live\""
);