Get page editable text data in repeater

lawrence whittemore asked on June 23, 2017 21:51

I have a whole bunch of pages and I am trying to pull them into a list with content from the editable text region on the page. Is there a way to get the content in the editable text region to pull into the repeater?

Recent Answers

Roman Hutnyk answered on June 23, 2017 21:57

Theoretically it is possible, however it is stored in [DocumentContent] column on CMS_Document table in XML form. So you may need to implement some custom method to parse XML and return the piece you need.

2 votesVote for this answer Mark as a Correct answer

Trevor Fayas answered on June 26, 2017 15:58 (last edited on June 26, 2017 15:59)

Here's some more sample code to help you, this shows how to get the Editable Fields from a Page's DocumentContent, how to get any widget on a page, and how to get any web part from a page template.

    int DocumentWithEdtiableWebPart = 1221;
    var PageItem = DocumentHelper.GetDocument(DocumentWithEdtiableWebPart, new TreeProvider());

    // Example parsing edtiable text values
    foreach (DictionaryEntry EditableWidgetNameKeyValue in PageItem.DocumentContent.EditableWebParts)
        string key = ValidationHelper.GetString(EditableWidgetNameKeyValue.Key, ""); // myeditabletextregion;32c2488d-ae29-441c-aaae-fca979a5914e
        string WebpartID = key.Split(';')[0]; //myeditabletextregion
        string WebpartGUID = key.Split(';')[1]; //32c2488d-ae29-441c-aaae-fca979a5914e
        string value = ValidationHelper.GetString(EditableWidgetNameKeyValue.Value, ""); //Test Content {^widget|(name)DateTime|(JsUseServerTime)False|(widget_displayname)Date+%26+time^}
        // Note, could not figure out how to resolve the inline widgets, the macro context resolve macros didn't work.

    // Example getting Widget values from Document
    XmlDocument pagewidgets = new XmlDocument();
    pagewidgets.LoadXml(string.IsNullOrWhiteSpace(PageItem.DocumentWebParts) ? "<page></page>" : PageItem.DocumentWebParts);
    foreach (XmlNode widgetNode in pagewidgets.SelectNodes("//webpart"))
        var theWidget = new WebPartInstance(widgetNode);
        var testValue = theWidget.GetValue("visible");

    // Example getting Page Template Web Parts from Page Template
    int PageTemplateWithEditableTextID = 26832;
    var PageTemplateWithEditableText = PageTemplateInfoProvider.GetPageTemplateInfo(PageTemplateWithEditableTextID);
    string TemplateWebPartsStr = PageTemplateWithEditableText.WebParts;
    XmlDocument TemplateWebParts = new XmlDocument();
    TemplateWebParts.LoadXml(string.IsNullOrWhiteSpace(PageTemplateWithEditableText.WebParts) ? "<page></page>" : PageTemplateWithEditableText.WebParts);
    foreach(XmlNode WebpartXml in TemplateWebParts.SelectNodes("//webpart"))
        var theWebpart = new WebPartInstance(WebpartXml);
        var testValue = theWebpart.GetValue("visible");

These use the namespaces

using CMS.PortalEngine;
using CMS.DocumentEngine;
using System.Xml;
using CMS.Helpers;
using CMS.Base;
using System.Collections;
using CMS.MacroEngine;
using CMS.Localization;
0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.