Skip to main content
Added line which initializes the TaxonomyFactory. Added comment about what's included in the returned keywordList
Source Link

You can do something like:

CompositeFiltervar taxonomyFactory = new TaxonomyFactory();
var filter = new CompositeFilter();
// all keywords 
filter.DepthFiltering(DepthFilter.UnlimitedDepth, DepthFilter.FilterDown);
// Creates a flat list
TaxonomyFormatter formatter = new TaxonomyListFormatter();
Keyword keywords = tftaxonomyFactory.GetTaxonomyKeywords(categoryId, filter, formatter);
IList keywordList = keywords.KeywordChildren; // list of Tridion.ContentDelivery.Taxonomies.Keyword 

Do note that when retrieving a flat list like this, you will lose all the information about hierarchy in the Taxonomy, which means that if you want to get the parent keyword of a keyword, you need to fetch that keyword again.

You can do something like:

CompositeFilter filter = new CompositeFilter();
// all keywords 
filter.DepthFiltering(DepthFilter.UnlimitedDepth,DepthFilter.FilterDown);
// Creates a flat list
TaxonomyFormatter formatter = new TaxonomyListFormatter();
Keyword keywords = tf.GetTaxonomyKeywords(categoryId, filter, formatter);
IList keywordList = keywords.KeywordChildren;

Do note that when retrieving a flat list like this, you will lose all the information about hierarchy in the Taxonomy, which means that if you want to get the parent keyword of a keyword, you need to fetch that keyword again.

You can do something like:

var taxonomyFactory = new TaxonomyFactory();
var filter = new CompositeFilter();
// all keywords 
filter.DepthFiltering(DepthFilter.UnlimitedDepth, DepthFilter.FilterDown);
// Creates a flat list
TaxonomyFormatter formatter = new TaxonomyListFormatter();
Keyword keywords = taxonomyFactory.GetTaxonomyKeywords(categoryId, filter, formatter);
IList keywordList = keywords.KeywordChildren; // list of Tridion.ContentDelivery.Taxonomies.Keyword 

Do note that when retrieving a flat list like this, you will lose all the information about hierarchy in the Taxonomy, which means that if you want to get the parent keyword of a keyword, you need to fetch that keyword again.

Source Link
Raimond
  • 7.3k
  • 18
  • 29

You can do something like:

CompositeFilter filter = new CompositeFilter();
// all keywords 
filter.DepthFiltering(DepthFilter.UnlimitedDepth,DepthFilter.FilterDown);
// Creates a flat list
TaxonomyFormatter formatter = new TaxonomyListFormatter();
Keyword keywords = tf.GetTaxonomyKeywords(categoryId, filter, formatter);
IList keywordList = keywords.KeywordChildren;

Do note that when retrieving a flat list like this, you will lose all the information about hierarchy in the Taxonomy, which means that if you want to get the parent keyword of a keyword, you need to fetch that keyword again.