...
There are three types of messages sent:
sportal365_custom_event
- This message is sent from the custom block to the CMS
Example:Code Block language json { "data": { "msg": "sportal365_custom_event", "payload": "{\"apples\":3, \"oranges\":2}" } }
When this message is sent, the CMS will respond with the next type of message
sportal365_custom_event_callback
- This message is always sent back to the client application so that the client can confirm that the data has been stored in the CMS successfully.
Example:Code Block language json { "data": { "msg": "sportal365_custom_event_callback", "payload": "{\"apples\":3, \"oranges\":2}" } }
sportal365_custom_event_onload
- This message is sent when an article containing the custom block is opened (edited) in the CMS. The stored data is sent back to the client javascript app so that the proper configuration can be displayed to the editor.
Example:Code Block language json { "data": { "msg": "sportal365_custom_event_onload", "payload": "{\"apples\":3, \"oranges\":2}" } }
Sample code
Now that you have a general idea of the types of messages sent back and forth we can continue with some sample code.
...
Code Block | ||
---|---|---|
| ||
const post = {"oranges":3, "apples":2}; window.parent.postMessage({ "data": {"msg": "sportal365_custom_event", "payload": JSON.stringify(post)}}, '*'); |
Receiving information from the CMS
List of CMS origins:
1. Sandbox - https://cms.sandbox.sportal365.com
2. Production - https://cms.sportal365.com
...