Portal Engine Questions on portal engine and web parts.
Version 5.x > Portal Engine > Using API to create page based on adhoc template View modes: 
User avatar
Member
Member
Steve - 6/14/2011 6:52:13 AM
   
Using API to create page based on adhoc template
Hi, I have successfully written code using the API to create a new page (menuitem) with a specific page template. However I now need to amend the page to make the template adhoc (still based on the required page template).

Anyone achieved this or got any pointers?

Thanks

Steve

User avatar
Kentico Support
Kentico Support
kentico_radekm - 6/16/2011 10:48:51 PM
   
RE:Using API to create page based on adhoc template
Hello.

If I am not wrong, you already solved it with my co-worker in e-mail conversation.

If the solution my co-worker provided to you works and you are OK with that, you can consider posting it here, so other customers can see it as well. Thank you.

Best Regards,
Radek Macalik

User avatar
Member
Member
Steve - 6/16/2011 11:55:14 PM
   
RE:Using API to create page based on adhoc template
Hi Radek,

Of course (I forgot I had posted here!). The solution which worked perfectly...

The code that you can use to clone the template as ad-hoc can be found in the btnClone_Click method in the following file ~\CMSModules\Content\CMSDesk\Properties\Template.aspx.cs.

In general, all you need to do is to get the the object of PageTemplateInfo class that represent the template you want to clone and then use the following code:

PageTemplateInfo newInfo = PageTemplateInfoProvider.CloneTemplateAsAdHoc(pldInfo, displayName, CMSContext.CurrentSite.SiteID);
PageTemplateInfoProvider.SetPageTemplateInfo(newInfo);

Hope that helps others

Steve

User avatar
Kentico Support
Kentico Support
kentico_radekm - 6/17/2011 12:01:00 AM
   
RE:Using API to create page based on adhoc template
Hello.

Thanks a lot, Steve!

Best Regards,
Radek Macalik