Newer Version Available

This content describes an older version of this product. View Latest

Set Up JSON in Your CMS Connection (Beta)

Does your website have JSON content such as blogs or articles? Do you store it in a CMS such as WordPress or Drupal? Sweet! You can render this content in your community using CMS Connect.

CMS Connect supports two basic types of JSON content. What they’re called in your CMS might be different than what another CMS calls them. In CMS Connect, to keep things simple, we call them Content Item and Content List.

An example of a content item is a single blog post. When it displays on a page, it’s the full blog post, not just a blurb about it. A content list, on the other hand, is a grouping of items such as blog posts. Most often, each item in a content list contains a link to those items. When setting up paths to your JSON content in a CMS connection, specify the type for each one: content item or content list.

  1. When creating or editing a CMS connection, in the JSON section, click Add JSON.
  2. Enter a name for your content. It can be anything you want. For example, Home Improvement.
  3. Select the type of content: Content List or Content Item. Is it a single article or blog post, such as “DIY Dryer Vent Cleaning”? Then it’s a content item. Or is it a grouping of items, such as “Home Improvement”, that has links to individual blog posts? Then it’s a content list.
  4. Enter the path to the JSON component in your CMS.
  5. Want to add more JSON? Repeat the above steps for each content item or content list to add.
  6. Click Save when finished to save the connection.

For instructions on adding JSON content to your community pages, see Add CMS Connect (JSON) Components to Your Community Pages (Beta)

Example

Here’s an example of a JSON content item in a CMS connection that uses Drupal. The path to the content item is structured as follows:

{baseUrl}/jsonApi/node/{contentType}/{id}

Here’s what the JSON payload structure for the content item looks like:

1{
2	"data": {
3		"type": "node--page",
4		"id": "c53cf56c-f70d-456e-838b-47788742b074",
5		"attributes": {
6			"nid": 5,
7			"uuid": "c53cf56c-f70d-456e-838b-47788742 b074",
8			"vid ": 5,
9			"langcode": "en",
10			"title": "This is an Example.",
11			"created": 1502133909,
12			"changed": 1502133933,
13			"body": {
14				"value": "This is the body.",
15				"summary ": ""
16			}
17		},
18		"relationships": {
19			"type ": {
20				"data ": {
21					"type": "node_type--node_type",
22					"id": "5b80bc9e-dc78-4612-add8-e46b2e2ff616"
23				}
24			}
25		}
26	}
27}

This example is taken from a Drupal CMS where @data is the parent node, and all attribute nodes to @data can be included in JSON expressions.

All JSON data sources must have 1 parent node. Multiple parent nodes in the JSON structure causes an error. For more information on constructing a data source that meets these criteria, see your JSON API options in your CMS.

Note

An example JSON expression for retrieving the title of the content is:

1@data/attributes/title

An example JSON expression for retrieving the body of the content is:

1@data/attributes/body/value

Your JSON expressions can be retrieved from multiple data sources and included in your community by creating JSON endpoints in your CMS Connect workspace. Your JSON expressions can handle any node depth.

Example

Here’s an example of a JSON content list in a CMS connection that uses Drupal. The path to the content list is structured as follows:

{baseUrl}/jsonApi/node/page

Here’s what the JSON payload structure for the content list looks like:

1{
2  "data": {
3    "type": "node--page",
4    "id": "c53cf56c-f70d-456e-838b-47788742b074",
5    "attributes": {
6      "nid": 5,
7      "uuid": "c53cf56c-f70d-456e-838b-47788742b074",
8      "vid": 5,
9      "langcode": "en",
10      "status": true,
11      "title": "Test",
12      "created": 1502133909,
13      "changed": 1502133933,
14      "promote": false,
15      "sticky": false,
16      "revision_timestamp": 1502133933,
17      "revision_log": null,
18      "revision_translation_affected": true,
19      "default_langcode": true,
20      "path": null,
21      "body": {
22        "value": "<p>Here is the header<\/p>\r\n",
23        "format": "basic_html",
24        "summary": ""
25      }
26    },
27    "relationships": {
28      "type": {
29        "data": {
30          "type": "node_type--node_type",
31          "id": "5b80bc9e-dc78-4612-add8-e46b2e2ff616"
32        },
33        "links": {
34          "self": "https:\/\/www.sandbox7.net\/jsonapi\/node\/page\/c53cf56c-f70d-456e-838b-47788742b074\/relationships\/type",
35          "related": "https:\/\/www.sandbox7.net\/jsonapi\/node\/page\/c53cf56c-f70d-456e-838b-47788742b074\/type"
36        }
37      },
38      "uid": {
39        "data": {
40          "type": "user--user",
41          "id": "d5808807-9f3d-4f10-a031-c3340172b88e"
42        },
43        "links": {
44          "self": "https:\/\/www.sandbox7.net\/jsonapi\/node\/page\/c53cf56c-f70d-456e-838b-47788742b074\/relationships\/uid",
45          "related": "https:\/\/www.sandbox7.net\/jsonapi\/node\/page\/c53cf56c-f70d-456e-838b-47788742b074\/uid"
46        }
47      },
48      "revision_uid": {
49        "data": {
50          "type": "user--user",
51          "id": "d5808807-9f3d-4f10-a031-c3340172b88e"
52        },
53        "links": {
54          "self": "https:\/\/www.sandbox7.net\/jsonapi\/node\/page\/c53cf56c-f70d-456e-838b-47788742b074\/relationships\/revision_uid",
55          "related": "https:\/\/www.sandbox7.net\/jsonapi\/node\/page\/c53cf56c-f70d-456e-838b-47788742b074\/revision_uid"
56        }
57      }
58    },
59    "links": {
60      "self": "https:\/\/www.sandbox7.net\/jsonapi\/node\/page\/c53cf56c-f70d-456e-838b-47788742b074"
61    }
62  },
63  "links": {
64    "self": "https:\/\/www.sandbox7.net\/jsonapi\/node\/page\/c53cf56c-f70d-456e-838b-47788742b074"
65  }
66}