Storing custom data for all page types
If you need to add raw data to a page, regardless of its page type and corresponding data types, use the NodeCustomData column of the CMS_Tree database table, or the DocumentCustomData column of the CMS_Document table.
The columns are not editable from the administration interface. You can access the columns in the API using properties of objects of the TreeNode class:
- TreeNode.NodeCustomData
- TreeNode.DocumentCustomData
Store and retrieve data using the indexer notation. The data is automatically serialized to an XML key-value structure and can be persisted in the database. For example, the custom data:
treeNode.NodeCustomData["Data1"] = "Value 1";
treeNode.NodeCustomData["Data2"] = "Value 2";
// Persists the changes in the database
treeNode.SubmitChanges(true);
Results in the following XML structure:
<CustomData>
<Data1>
Value 1
</Data1>
<Data2>
Value 2
</Data2>
</CustomData>
Access the data in code using specified key values:
// Retrieves 'Value 1'
var data = treeNode.NodeCustomData["Data1"];