1-888-365-2779
+1-888-365-2779
Try Now
More in this section

Forums / Developing with Sitefinity / Pull Categories

Pull Categories

2 posts, 0 answered
  1. Coty
    Coty avatar
    29 posts
    Registered:
    25 Aug 2006
    13 Feb 2013
    Link to this post

    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();

  2. Coty
    Coty avatar
    29 posts
    Registered:
    25 Aug 2006
    13 Feb 2013 in reply to Coty
    Link to this post

    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
    }
2 posts, 0 answered