How to get all news categories programatically.
I am using sitefinity 4.3. I need a code to get all news categories. I cannot able to get this in forum section.
Can u pls suggest ASAP.
Any reply pls...
Hey man any reply...
Hey guys,
Can you reply for this..We are using your product which has to be supported properly. There are too many issue's guys.
How you are able to release like this??
Hi Sathiyaseelan,
As per your license agreement our support services are offered from Monday till Friday which excludes Saturday and Sunday. Also the guaranteed response time for your license is 72h which includes the forum type of conversation. More information about the support plans can be found here.
In order to achieve the desired scenario you need to get all categories and see which one of them is used in the news items. You can refer to our documentation and especially the section regarding the hierarchical taxonomies:
http://www.sitefinity.com/40/help/developers-guide/sitefinity-essentials-taxonomies-hierarchical-taxonomies-hierarchical-taxonomy-api.html
http://www.sitefinity.com/40/help/developers-guide/sitefinity-essentials-taxonomies-associating-items-with-taxa.html
You can also use the following code:
var dataItem = App.WorkWith().News().Get().Where(p => p.Title == Newsitemtitle).First();
var propDesc = OrganizerBase.GetProperty(dataItem.GetType(), "Category") as TaxonomyPropertyDescriptor;
if (propDesc != null)
var taxonIds = propDesc.GetValue(dataItem) as IList<
Guid
>;
var taxonomyManager = TaxonomyManager.GetManager();
var taxa = new List<
string
>();
foreach (var taxonId in taxonIds)
taxa.Add(taxonomyManager.GetTaxon(taxonId).Title);
Hello,
I found it by digging. Your reply was not good enough still.
/* List of all categories */
Telerik.Sitefinity.Taxonomies.TaxonomyManager manager1 = Telerik.Sitefinity.Taxonomies.TaxonomyManager.GetManager();
IList categoryList = manager1.GetTaxa<Telerik.Sitefinity.Taxonomies.Model.HierarchicalTaxon>()
.Where(t => t.Taxonomy.Title == "Categories")
.Select(t =>
new Id = t.Id, Name = t.Title.ToString() )
.OrderByDescending(t => t.Name)
.ToList();
How to get the categories associated to a particular news by passing News ID..? Can I get at-least an answer for this.
Thanks,
Sathiyaseelan,
This post will help you. I've tested the code and know it works.
Hope that helps!