Pull Categories

Posted by Community Admin on 04-Aug-2018 18:28

Pull Categories

All Replies

Posted by Community Admin on 13-Feb-2013 00:00

Is there a way to pull Categories from code behind?

I have a category called Regions, (under Content > Categories) that has several subcategories.  I want to get all the children of the parent category (Regions).

I thought I could just pull the Region category, and then loops through it's children but it is returning null.

var taxonomy = manager.GetTaxonomies<HierarchicalTaxonomy>().Where(t => t.Name == "regions").Single();

Posted by Community Admin on 13-Feb-2013 00:00

Ok nevermind I figured it out:

To get Taxa by it's Parent Name:

TaxonomyManager manager = TaxonomyManager.GetManager();
var taxa = manager.GetTaxa<HierarchicalTaxon>().Where(t => t.Parent.Name == "regions");
 
foreach (var item in taxa)
   //Do Stuff

This thread is closed