Documentation Center

Retrieving Keyword properties

A taxonomy consists of Keywords organized in a tree hierarchy. Keywords can have properties which can determine, for example, whether to display this Keyword or not in navigation. Use the API to retrieve a Keyword's properties and relations.

To get to a Keyword, use the API to get the root Keyword, then traverse the tree to access all child Keywords in the Keyword branch. Keywords have a system property called Key; metadata; and relations to other Keywords.

Key property

Use a Keyword's Key property to associate an external resource to the Keyword, for example, a product ID. Given a Keyword, use the GetKeywordKey method to retrieve the Key property (ASP.NET example):

TaxonomyFactory taxonomyFactory = new TaxonomyFactory();
Keyword keydFacet = taxonomyFactory.GetTaxonomyKeyword("tcm:9-3-1024");
String keyValue = keydFacet.getKeywordKey();
Keyword metadata

If a Keyword has metadata defined, you can retrieve this metadata from the KeywordMeta property, which is a dictionary of name-value pairs (ASP.NET example):

CustomMeta keywordMeta = null;
IDictionary metaNameDictionary = null;
IEnumerator metaNameEnumerator = null;
NameValuePair currentMeta = null;
DictionaryEntry currentMetaDE;

TaxonomyFactory tf = new TaxonomyFactory();
Keyword currentFacet = tf.GetTaxonomyKeyword("tcm:9-3-1024");

keywordMeta = currentFacet.KeywordMeta;
if (keywordMeta != null) {
	metaNameDictionary = keywordMeta.NameValues;
	metaNameEnumerator = metaNameDictionary.GetEnumerator();
	if (metaNameEnumerator != null) {
		while (metaNameEnumerator.MoveNext()){
			currentMetaDE = (DictionaryEntry)metaNameEnumerator.Current;
			currentMeta = (NameValuePair)currentMetaDE.Value;
			if (currentMeta != null) {
				Response.Write(currentMeta.Name + " " + currentMeta.Value + currentMeta.ValueType);
			}
		}
	}
}
Related Keywords

In addition to a parent and children, a Keyword can also have a relationship to other Keywords, indicating, for example, a 'see-also' relationship. The following ASP.NET implementation retrieves the related Keywords of a Keyword as a set of strings (Content Manager URIs):

String[] relatedKeywordURIs = null;
String selectedKeywordURI = "tcm:12-800-1024";
Keyword selectedKeyword = null;
TaxonomyFactory taxonomyFactory = new TaxonomyFactory();

selectedKeyword = taxonomyFactory.GetTaxonomyKeyword(selectedKeywordURI);
relatedKeywordURIs = selectedKeyword.GetRelatedKeywordUris();