How can I get all block within a folder progmmatically?

 

Dear all,

 

I have created a category called "Jobs" where I add all the "JobBlock" I create. I have a Folder named "Jobs" in the "Global Library" where I have already created 3 "JobBlock" {Job01, Job02, Job03} and I would like to know how can I get all those instances whithin the controller?

var categoryList = CategoryList.LoadCategories();
var categoryId = categoryList.FirstOrDefault(c => categoryList.GetCategoryName(c) == "Jobs");

How can I get a list of "JobBlock"s?

Best regards,

Daniel

#65251 Jan 23, 2013 17:51
  •  

    Hmm, categories and block folders aren't related. To get all blocks in a folder you need a reference to the folder. You could for instance create a property of type ContentReference on the start page and have that point to the folder. Then you simply use the GetChildren method located on IContentLoader/IContentRepository/DataFactory with the reference as argument.

    Getting all blocks categorized with a specific category is another question, but unless you actually need that, I would recommend using the above approach.

    #65252 Jan 23, 2013 20:08