How to change property of web part on page template programmatically

Technical support leader

Juraj Ondrus asked on November 6, 2009 07:11

How to change property of web part on page template programmatically

Correct Answer

Juraj Ondrus answered on November 6, 2009 07:11

You can use following example code to change property of web part (breadcrumbs) on some page template (cms.blog):

// get PageTemplateInfo according to PageTemplateCodeName
PageTemplateInfo pti = PageTemplateInfoProvider.GetPageTemplateInfo("CMS.Blog");

// get WebPartInstance according to WebPartID

WebPartInstance webPart = newInfo.GetWebPart("breadcrumbs");

// set web part property
if (webPart != null)
{
webPart.SetValue("Path", "/%");
}


// save changes to page template

CMS.PortalEngine.PageTemplateInfoProvider.SetPageTemplateInfo(newInfo);

0 votesVote for this answer Unmark Correct answer

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