I have a Doctype that has 4 Templates assigned to it. This Doctype has NO default template assigned. The Doctype also has a Property (named 'Type') assigned to it using a Datatype I created. The Datatype is a radio list with 4 values. The values are the aliases of the templates assigned to the Doctype. I'm trying to find a way for Umbraco to automatically assign one of the four allowed templates to the created node based on the selection of the Property 'Type'. For example, if a user selected the first option in the radio input, the Doctype would be assigned the template with the corresponding alias programmed in the Datatype.
Is this possible? I'm thinking a custom codebehind script might handle this. Ideas?
It sounds like you might want to hook into the ContentService.Saving event. In the event handler you'll be able to check the property values of the nodes being saved and modify whatever properties you need.
Automated template assignment on publish?
I have a Doctype that has 4 Templates assigned to it. This Doctype has NO default template assigned. The Doctype also has a Property (named 'Type') assigned to it using a Datatype I created. The Datatype is a radio list with 4 values. The values are the aliases of the templates assigned to the Doctype. I'm trying to find a way for Umbraco to automatically assign one of the four allowed templates to the created node based on the selection of the Property 'Type'. For example, if a user selected the first option in the radio input, the Doctype would be assigned the template with the corresponding alias programmed in the Datatype.
Is this possible? I'm thinking a custom codebehind script might handle this. Ideas?
Hi Robert,
It sounds like you might want to hook into the ContentService.Saving event. In the event handler you'll be able to check the property values of the nodes being saved and modify whatever properties you need.
Hi Robert,
here is a similar post with a solution:
https://our.umbraco.org/forum/templating/templates-and-document-types/40276-Programmatically-setting-a-template-on-a-document-in-V6-API
You need the ContentService and FileService.
Best, Sören
Robert here is a good video in the service api's
http://stream.umbraco.org/video/9920652/master-the-service-apis
is working on a reply...