Portal Engine Questions on portal engine and web parts.
Version 7.x > Portal Engine > Document Template when creating page View modes: 
User avatar
Certified Developer 13
Certified Developer 13
jay@3degreesnorth.com.au - 11/16/2013 5:30:18 PM
   
Document Template when creating page
I'm looking for a way (programmatically) to apply a specific page template to a page during creation.

I've set a default page template for this document type in Site Manager - however that doesn't apply that template - it just inherits from the parent.

I guess I can solve this two ways - figure out why the default page template isn't working OR do it in my code when I create the document.

Any help appreciated.

Thanks

Jay

User avatar
Kentico Consulting
Kentico Consulting
Kentico_RichardS - 11/17/2013 3:56:28 AM
   
RE:Document Template when creating page
Hi Jay,

Thank you for your message.

If you set the Default page template in the General tab in document types it should indeed assign this template to the document if you create it in the CMS desk automatically. Do you have the Show template selection unchecked?

Can you maybe try this with some other document type just to check if it works?

I tried it on my end with a simple Article document type and it was working correctly.

Let us know for further assistance.

Kind regards,
Richard Sustek

User avatar
Certified Developer 13
Certified Developer 13
jay@3degreesnorth.com.au - 11/17/2013 4:38:57 AM
   
RE:Document Template when creating page
Hi

Thanks but I'm trying to do this all programmatically. Any assistance with code?

Jay

User avatar
Kentico Consulting
Kentico Consulting
Kentico_RichardS - 11/17/2013 6:09:37 AM
   
RE:Document Template when creating page
Hi Jay,

Have you already registered the on insert global event when you are creating document type? (example here http://devnet.kentico.com/docs/devguide/index.html?event_handlers_overview.htm )

If so, you can simply set the DocumentPageTemplateID to the ID of the template of your choosing.

Example can be:

e.Node.SetValue("DocumentPageTemplateID", "someid");
e.Node.Update();


Kind regards,
Richard Sustek