Skip to main content

Deprecation warning

Taxonomy in entries is deprecated and may be removed from future releases of Contensis. We strongly recommend using content types and entries to categorise content.

Taxonomy nodes can be retrieved using the following methods, either by key or by path. The localization can be included as a parameter to determine the language the nodes should be returned as. The order by default is set to 'alphabetical', but an order of 'defined' (which is the order set in the UI) can also be used.

The childDepth parameter is used to reduce the number of service calls if child and descendant nodes are being iterated, which will potentially increase performance.

getNodeByKey

A function that uses a taxonomy node key to retrieve taxonomy nodes. It returns a Promise that will resolve with a TaxonomyNode instance.

Syntax

Parameters

key

Type: string
The key for the taxonomy, which is a forward-slash delimited set of integer values, e.g. 0/2/734

or

key

Type: TaxonomyGetNodeByKeyOptions
An object that supports multiple configuration options

Example

TypeScript
const node = await client.taxonomy.getNodeByKey("0/1");

console.log(node);
TypeScript
const node = await client.taxonomy.getNodeByKey({
  key: "0/1",
  order: "defined",
  childDepth: 10,
  language: "fr-FR",
});

console.log(node);

getNodeByPath

A function that uses a taxonomy node path to retrieve taxonomy nodes. It returns a Promise that will resolve with a TaxonomyNode instance.

Syntax

Parameters

path

Type: string
The path for the taxonomy, which is a forward-slash delimited set of string values, e.g. "Root/Movies/Genres/Comedy"

or

path

Type: TaxonomyGetNodeByPathOptions
An object that supports multiple configuration options

Example

TypeScript
const node = await client.taxonomy.getNodeByPath("Root/StructuredContent");
console.log("Taxonomy getNodeByPath:");
console.log(node);
TypeScript
const node = await client.taxonomy.getNodeByPath({
  path: "Root/StructuredContent",
  order: "defined",
  childDepth: 10,
  language: "fr-FR",
});
console.log("Taxonomy getNodeByPath with options:");
console.log(node);

resolveChildren

A function that uses a taxonomy node key or a taxonomy node instance to resolve taxonomy nodes. It returns a Promise that will resolve with a TaxonomyNode instance.

Syntax

Parameters

node

Type: string
The key for the taxonomy, which is a forward-slash delimited set of integer values, e.g. 0/2/734

or

node

Type: TaxonomyNode
A taxonomy node object

or

node

Type: TaxonomyResolveChildrenOptions
An object that supports multiple configuration options

Example

TypeScript
const node = await client.taxonomy.resolveChildren("0/1");

console.log("Taxonomy resolveChildren with taxonomy node key:");
console.log(node);
TypeScript
const node = await client.taxonomy.resolveChildren({
  key: "0/1",
  name: "",
  path: "",
  hasChildren: true,
});

console.log("Taxonomy resolveChildren with taxonomy node:");
console.log(node);
TypeScript
const node = await client.taxonomy.resolveChildren({
  key: "0/1",
  order: "defined",
  childDepth: 10,
  language: "fr-FR",
});
console.log("Taxonomy resolveChildren with options and taxonomy node key:");
console.log(node);
TypeScript
const node = await client.taxonomy.resolveChildren({
  node: { key: "0/1", name: "", path: "", hasChildren: true },
  order: "defined",
  childDepth: 99,
  language: "fr-FR",
});
console.log("Taxonomy resolveChildren with options and taxonomy node:");
console.log(node);

Still need help?

If you still need help after reading this article, don't hesitate to reach out to the Contensis community on Slack or raise a support ticket to get help from our team.
New support request