API
Version 7.x > API > Make DefaultText editable View modes: 
User avatar
Member
Member
BeerWill - 3/16/2013 11:33:04 PM
   
Make DefaultText editable
Having added a widget containing an EditableText webpart to a page via the API, I need to access the content.

I can write to various properties, including the DefaultText. This correctly shows on the live page, but does not show in the Editor on the page.

I found the following FAQ regarding v6, but it doesn't seem valid for v7.
http://devnet.kentico.com/FAQs/Content-Management/How-to-make-the-Default-text-property-of-an-Editab.aspx

So can someone tell me how to make the DefaultText of editable text web part editable on a Page tab in v7.0 ?

Thank you,

Will.

User avatar
Member
Member
BeerWill - 3/17/2013 10:02:46 PM
   
RE:Make DefaultText editable
I would still like to know how to make the DefaultText of an Editable Text widget editable in the Page editor, but overall my problem is actually solved.

In case someone else is interested, I was creating a Widget programmatically via the API, and adding it to an individual page, but couldn't access the content. You can access properties of the widget such as DefaultText and Container, but not the actual content.

The trick was that you need to add the widget to the page, save the page, then re-open the page. Now the widget is in the document, the content is writeable via the usual WebParts method.

eg.
// save previously created widget (based on EditableText webpart) back to page
CMSPortalManager.SaveTemplateChanges(docPageInfo, templateInstance, WidgetZoneTypeEnum.Editor, ViewModeEnum.Edit, tree);
// re-get page info and access widget content
insertedNode = DocumentHelper.GetDocument(insertedNode, tree);
myPageInfo = PageInfoProvider.GetPageInfo(insertedNode.DocumentGUID);
myPageInfo.EditableWebParts["Added_Widget_ID"] = "Content goes here";

Will.

User avatar
Kentico Customer Success
Kentico Customer Success
kentico_martind2 - 3/18/2013 9:01:29 AM
   
RE:Make DefaultText editable
Hi Will,

Thanks for the updated info, great!

The reason why you have to save a widget first is that before saving it actually has not any content, so it can't be edited, but very smart solution.

Best regards,
Martin Danko