In Salesforce, there is an option to connect a Salesforce Community with external CMS websites using the CMS Connect. It provides the default access for the following CMS sources: AEM, Drupal, WordPress, SDL and Sitecore.
Why CMS Connect?
Salesforce Basic Setup
- CORS Whitelist
- Remote Site Settings
- CSP Trusted Site
CMS Connect uses Cross-Origin Resource Sharing (CORS) to access external content. Make sure to add Community Host to the list of trusted hosts in the CORS header in your CMS system.
Note: In the blurred field above, you should place your WordPress site Host URL.
CMS Connection Setup
1.In Quick find search box, find All Community –> Workspaces –> CMS Connect
2.Click “New” button to add CMS Connection and provide the connection details Name, CMS Source, Connection Type and Server URL (Host URL).
3.Using JSON option, you can connect the CMS Rest API URL and provide the Content Type Name. Click the “Add Content Item” button to create the access to CMS data.
4.In Content item, provide the Name, Path and Node Path (optional) and Path field holds the Rest API URL.
6.Click the “Save” button to complete the connection setup.
7.Finally, click the down arrow and “Use in Builder” option to make these changes available in Community Builder.
WordPress Posts & REST API Access
1.Log into WordPress and add couple of records to Post content type
2.Added records could be accessible through Rest API URL and it can Public / Authenticated types
3.Rest API response will be JSON format as like the below screenshot
Use CMS Connect (JSON) in Community
1.Go to Community Builder –> click on Lightning icon from the navigation
2.In Components, search “CMS” keyword and find the CMS Connect (JSON)
3.Drag and Drop that component and place it into your community page.
4.Click on the CMS Connect (JSON) component and see the CMS Connect (JSON) popup as like below screenshot.
5.In Connection section, select the given CMS Source and JSON Content as similar in CMS Connection setup
6.In Content List Layout section, choose the Layout Type, Items Per Page and Columns to display the data
7.In Content Item Layout section, enter the Title, Published On, Body and Image Source from the Rest API response.
a. Title[rendered] -> @title/rendered
b. Date -> @date
c. Content[rendered] -> @content/rendered
The Rest API response should be changed as mentioned above.
8.In Navigation section, enter the Link Text and Page Type
9.Finally, make sure the entered content items match with Rest API response. Now, “Publish” the Community.
10.Log in as a Community user and navigate to the Posts page. It will display the latest Posts from the WordPress CMS data in Salesforce Community.
- CMS Connect reduces the code changes and with the help of configuration setup user can access the CMS data
- It is more secured and supports the authenticated method to access the protected Rest API data
- Admin user can easily understand the connection setup and add the content items based on their needs
- Admin user does not need to depend on Developers and it is easily manageable