# Articlegroup

An object representing an article group.

# Properties

Property Type Description
uid integer The unique identifier of the article group.
name object Name of the article group, by language.
url object URL of the article-group page, by language.
baseName object The base name that is used when generating a URL for the article group, by language. Unless otherwise specified then baseName is generated from name.
children array A list of unique identifiers for all the article groups immediately below the article group, if any. For administrators only.
hidden boolean Whether the article group and its contents are hidden.
parent integer The unique identifier of the parent article group, if any.
description object Article-group description by language, e.g. {"en": "Organic shampoo for dry hair", "sv": "Ekologiskt schampo för torrt hår"}.
pageTitle object The page title, by language.
metaDescription object Text to be used for the HTML meta element named "description", by language.
metaKeywords object Text to be used for the HTML meta element named "keywords", by language.
image string URL to an article group image.
pageItems array A list of custom page items that's connected to this articlegroup.

# Methods

# count

Takes a filter object and returns the number of article groups found, as an integer.

# Parameters

A filter object specifying which article groups to count. See Filter objects on the page List selection.

# Example

The request below returns the number of article groups where the name in English starts with "Organic".

Articlegroup.count({
  "/name/en": {
    "startsWith": "Organic"
  }
})

# create

Creates a new article group. This is a shorthand for set with the unique identifier as null.

# Parameters

Parameter Description
patch An object containing the properties and values to set for the new article group.
query A query specifying what to return after article group creation has been successful (optional). See Query language.

# get

Fetches information about an article group.

# Parameters

Parameter Description
uid The unique identifier of an article group.
query Which info to return. See Query language.

# Example

Articlegroup.get(12345, {
  "uid": true,
  "name": [
    "en",
    "sv"
  ],
  "children": true
})

# getSchema

Fetches the JSON Schema which can be used for client-side validation.

# Parameters

The unique identifier of an article group or null for a new article group.

# list

Fetches multiple article groups as an array of article-group objects.

# Parameters

Parameter Description
query Which info to return. See Query language.
selection Which article groups to list. See List selection.

# Filters

Apart from filtering on the properties using their JSON pointers, the following filters exist:

Filter Description
empty Article groups without articles, including in any subgroups (children).

The following orderings are available:

  • uid
  • name
  • position

# Example

The following request returns an array of all the article groups at the root level, i.e. all of those without a parent, where the name in English starts with "Organic":

Articlegroup.list([
  "uid",
  "name"
], {
  "filters": {
    "/parent": null,
    "/name/en": {
      "startsWith": "Organic"
    }
  }
})

# set

Creates or updates an article group.

# Parameters

Parameter Description
uid The unique identifier of an article group to update or null to create a new one.
patch An object containing the properties and values to set for the article group.
query A query specifying what to return after a successful set (optional). See Query language.

# Example

Articlegroup.set(12345, {
  "name": {
    "en": "Organic shampoo",
    "sv": "Ekologiskt schampo"
  }
}, [
  "uid",
  "name"
])

# normalize

Fetches a normalized version of the patch. Uses the same parameters as set and validate. While set also normalizes the patch, before writing to the file, normalize only returns the normalized patch. For all the properties with number types, integers or floating-point values in strings are converted to number literals. A normalization error is thrown when we are unable to convert a string to a number literal.

# Parameters

Parameter Description
uid The unique identifier of an article or null to create a new article group.
patch An object containing the properties and values to normalize.

# Example

Articlegroup.normalize(123456, {
  "parent": "1"
})

# validate

Validates the data to be set. The performed validation is the same as in set; it validates the resulting object and includes all the required properties. However, nothing is saved.

# Parameters

Parameter Description
uid The unique identifier of an existing article group or null.
patch An object containing the properties and values to set before validating.

# Returns

An array of validation-error objects, each containing the keys pointer (a property referenced using a JSON Pointer) and message (a readable text in the language of the context). If there are no validation errors, then an empty array is returned.

# tree

Fetches multiple article groups as a tree.

# Parameters

Parameter Description
root The unique identifier of the Articlegroup as the starting point for the tree. Use null for the root level.
query Which info to return. See Query language.
selection Which article groups to list. See List selection.
depth The number of levels in the article-group hierarchy (optional).

# Example

Articlegroup.tree(null, [
  "uid",
  "name",
  "url",
  "children"
], true)