Hi,
I'm adding new pages and inserting text into the editable web part through the API. I'm seeing something in the database that concerns me. When I create a new page and insert some text the DocumentContent field in the CMS_Document table looks like this:
<content><webpart id="maincontent"><![CDATA[This is some more text]]></webpart></content>
However, I noticed that the content on other pages like this one looked like this:
<content><webpart id="maincontent;82037d0f-044c-4477-90da-2c3bed5738b1"><![CDATA[<p>
This is some more text</p>
]]></webpart></content>
The difference is the addition of the GUID after the webpart id. If I edit my page and save it, the GUID then appears like the others.
What's going on here?
Here is my code:
UserInfo user = UserInfoProvider.GetFullUserInfo("administrator");
TreeProvider tree = new TreeProvider(user);
TreeNode parentNode = tree.SelectSingleNode(CMSContext.CurrentSiteName, "/", "en-us");
System.Guid g = new Guid();
int nodeID = -1;
if (parentNode != null)
{
TreeNode newNode = TreeNode.New("CMS.MenuItem", tree);
newNode.DocumentName = "My New Document";
newNode.DocumentCulture = "en-us";
newNode.DocumentPageTemplateID = 77;
newNode.Insert(parentNode);
g = newNode.DocumentGUID;
nodeID = newNode.NodeID;
}
PageInfo pi = PageInfoProvider.GetPageInfo(g);
pi.EditableWebParts["mainContent"] = "This is some even more text";
TreeNode tn = tree.SelectSingleNode(nodeID);
tn.SetValue("DocumentContent", pi.DocumentContent);
tn.Update();
Also, what is the difference between using TreeNode.Update and DocumentHelper.UpdateDocument? I've seen both in your examples.
Thanks,
Scott