Newer Version Available
Example: Connect JSON Content to Your Community
Let’s say you have a WordPress site called Capricorn Cafe. This example shows how to configure a CMS Connect (JSON) component that pulls blog content from that site into your community.
- Content list—https://public-api.wordpress.com/rest/v1.1/sites/capricorncafeblog.wordpress.com/posts?number=6&page=1
- Content item—https://public-api.wordpress.com/rest/v1.1/sites/capricorncafeblog.wordpress.com/posts/38
Set Up JSON in Your CMS Connection
Suppose that you want to pull in a series of blogs with links to the individual blogs in full.
- Create a CMS connection.
- Under Connection Details, provide the following information.
- Name—Capricorn
- CMS Source—WordPress
- Connection Type—Public
- Server URL—https://public-api.wordpress.com
- Because you’re adding JSON content, don’t enter an HTML root path, CSS, or scripts. Those sections are for CMS HTML connections.
- In the JSON section, click Add JSON.
- For Content Type Name, enter Blog Feed.
- Click Add content list and provide the following information.
- Name—Blog List
- Path—rest/v1.1/sites/capricorncafeblog.wordpress.com/posts?number={itemsPerPage}&page={pageNumber}
- Node Path—posts
- To generate a detail page and a link for each blog in the list, make sure that the
content type has both a content item and a content list. Click Add content
item and provide the following information.
- Name—Blog Item
- Path—rest/v1.1/sites/capricorncafeblog.wordpress.com/posts/{component}
- ID Path—ID
- Title Path—title
- Click Save.
Add the Blog Series to Your Page
- In the Community Builder, drag a CMS Connect (JSON) component to a page.
- Open the property editor, and configure the connection.
- CMS Source—Capricorn
- JSON Content—Blog List
- Component Path—For a content list, leave this field blank.
- Under Content List Layout, select Grid, and provide the following information.
- Items Per Page—Enter a value, for example, 5.
- Columns—Enter a value, for example, 2.
- Under Content List Item Layout, select Card, and enter properties
for the layout.
- Title—@title
- Author—@author/name
- Published On—@date
- Body—@content
- Image Source—@featured_image
- Under Navigation, set up how the list redirects to a specific blog.
- Link Text—Read More
- Type—Community Page
- Click Save in the property editor. After saving, you see the name created for the detail page, for example, Capricorn-Blog_Feed. The detail page shows the full blog item in the series.
Your community page now displays the blog series using your CMS content. After you publish the changes, you can click the Read More link under a blog item in the series. The link takes you to a detail page generated dynamically for the blog.
After you publish your community, you can change your CMS connection settings. For example, suppose that you modify a content list path to point to news items instead of blog items. Because CMS connections are cached for the guest user, republishing your community allows the guest to see the update without a delay.
Add a Single Blog Item to a Page
But what if all you need is a single blog or news item that you want to feature on your community page?
- Create a CMS connection. In this example, let’s reuse the same connection.
- In the Community Builder, drag a CMS Connect (JSON) component to a page.
- Open the property editor, and configure the component.
- CMS Source—Capricorn
- JSON Content—Blog Item
- Component Path—Enter the ID for the blog, for example, 38
- Under Content List Item Layout, select Detail, and enter
properties for the item’s layout.
- Title—@title
- Author—@author/name
- Published On—@date
- Body—@content
- Image Source—@featured_image
- Click Save.
Congratulations! Your community page is now configured to display your blog item.