API Questions on Kentico API.
Version 5.x > API > API Call to Get Fully Rendered Chunk of Content View modes: 
User avatar
Member
Member
mjohnson-jminsure - 10/28/2011 1:48:19 PM
   
API Call to Get Fully Rendered Chunk of Content
There are a few code examples out there for retrieving, through the API, pieces of content, like news items.

Are there code examples for retrieving fully rendered html for various web parts? For example, are there API examples in retrieving the rendered HTML for:

* a menu
* an entire zone on a template
* an editabletext web part
* an editableimage web part

My goal is to pull content into another web application that's been defined in the CMS.

Thanks for any help.

--Mark

User avatar
Kentico Developer
Kentico Developer
kentico_ivanat - 11/7/2011 2:25:26 AM
   
RE:API Call to Get Fully Rendered Chunk of Content
Hi,

here is a code example which could help you. Using the code you can get the content of editable text web part or get property of some general web part:


PageInfo pi = PageInfoProvider.GetPageInfo("CorporateSite", "/", "en-us", "", false,ConnectionHelper.ContextConnection);

// content of editable text web part
// string editableHTML = pi.EditableItems["editabletextwebpartID"];

PageTemplateInfo pt = pi.PageTemplateInfo;
WebPartZoneInstance wpzi = pt.GetZone("zoneLogo");
WebPartInstance wpi = wpzi.GetWebPart("ScrollingNews");

// or GetValue("ContentBefore")
wpi.SetValue("ContentBefore", "myValue");

//Save info if needed
PageTemplateInfoProvider.SetPageTemplateInfo(pt);


Navigation web part has a property RenderedHTML which you could use to get the code generated by the web part.

Best regards,
Ivana Tomanickova