XML Data Synchronizer
1. Introduction
This guide will quickly walk you through installing and configuring a custom data synchronizer on your site. It assumes that you have a recent version of PHP installed on your web server and that you are comfortable with Cascade. Knowledge of PHP is also useful, but not necessary to use this guide.
2. Components
There are several components to the script including the script itself, the configuration page, the example XML feed, and the log file. The script will read its configuration from a configuration file that you will publish (with the use of a data definition), search the XML feed for new pages, upload these pages, and keep a log of which pages have been uploaded.
3. The Configuration Page
Create a page called "data-sync-config.xml", and give it a .php publish extension. Then give it the "data-sync-config-data-definition.xml" data definition. Supply a valid user-name, password, and server URL. After this is done, supply the URL to the XML feed, as well as a relative path to the log file. Next, supply a base path to be used for all page uploads. Then, supply the configuration, metadata, and data definition paths. Publish this page and "data-sync.php" in the same folder, and your script will be ready for use.
4. complexType Attributes:
All fields in the system-data-structure that are not plain text fields or groups must be labeled as such with a complexType attribute. The following values are acceptable: xhtml, checkbox, and selector. For example, if you have a wysiwyg field with the label "stuff" inside of your system-data-structure, the element for this in your XML will be
<stuff complexType="xhtml">
The same holds true for checkboxes and selectors.
5. The Example XML
The Example XML should have an <events> root element. Each event should be inside of an <event> element, with an id that is unique for each event. Inside of the event, copy/paste what is expected inside of the system-data-structure. After this, add all complexType attributes that are needed, as mentioned above. Any fields that are not listed in this block will appear with their default values. For example, using the General/demo data definition, the following is a valid event listing:
<event id="3957"><pr-contact>
<call-out>call out</call-out>
<value>value 1</value>
<value>value 2</value>
<date>06-29-2006</date>
<opening-paragraph>06-29-2006</opening-paragraph>
<visual-paragraph complexType = "xhtml">
<ul>
<li>example...example<h1>stuff</h1><h3>more examples</h3>fasdf</li>
</ul>
</visual-paragraph>
<s_p_checkbox2_product complexType="checkbox">
<value>CMS 1</value>
<value>CMS 2</value>
<value>CMS 3</value>
</s_p_checkbox2_product>
</pr-contact>
<s_p_dropdown>CMS 1</s_p_dropdown>
<s_p_multi-selector complexType="selector">
<value>CMS 2</value>
<value>CMS 1</value>
</s_p_multi-selector>
</event>
6. Using
To use the script, upload the script to your CMS, and publish it. Fill in all fields in the configuration page, and then publish it as well. Once both of these are published, run the script from your server. All pages listed in the example XML feed that are not already in the CMS and are not in the log file will be added. Likewise, any pages that are in the XML feed and are in the CMS, but are not in the log file will be edited. Therefore, to change a page that has already been edited, simply remove it from your log file and run the script again.
Data Synchronizer Files
- data-sync-PHP.zip
This zip file contains the necessary script and XML files to use the data sync tool. - event-data-definition.xml
This is an example data definition for a calendar event that is synchronized from a third-party system via web services. - data-sync-config-data-definition.xml
This is the data definition XML used to visually manage the config file. - data-sync-config-xml-php.txt
This is an example XML config file published from the CMS. - data-sync-log-xml-php.txt
This is an example XML log file of the events that have already been processed. - data-sync-php.txt
This is the main script code to synchronize XML from an external source with the CMS. - example-data.xml
This is an example XML data file that the script will synchronize against.