Access to Blog Post Categories

Posted by Community Admin on 04-Aug-2018 17:56

Access to Blog Post Categories

All Replies

Posted by Community Admin on 15-Aug-2011 00:00
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?
Posted by Community Admin on 17-Aug-2011 00:00
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
Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Posted by Community Admin on 17-Aug-2011 00:00
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.
Posted by Community Admin on 17-Aug-2011 00:00
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
Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Posted by Community Admin on 02-Apr-2015 00:00
Is it possible to retrieve Newsitem based on Taxonomy like the blogpost, as u mentioned here
Posted by Community Admin on 06-Apr-2015 00:00
Hi Kalyani,

You can try this approach:
Add the following using:
using Telerik.Sitefinity.Data.Linq.Dynamic;

and filter the NewsItems by the following sample code:
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\"");

I hope this helps.

Regards,
Svetoslav Manchev
Telerik
 
Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Sitefinity CMS Ideas&Feedback Portal and vote to affect the priority of the items
 
This thread is closed