Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Robert Valcourt 70 posts 103 karma points
    Jun 16, 2015 @ 21:53
    Robert Valcourt
    0

    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?

  • Steven Harland 78 posts 518 karma points c-trib
    Jun 18, 2015 @ 12:56
    Steven Harland
    0

    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.

  • Sören Deger 733 posts 2844 karma points c-trib
    Jun 18, 2015 @ 13:08
    Sören Deger
    0

    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

  • Keith R Hubbard 175 posts 403 karma points
    Jun 19, 2015 @ 17:28
    Keith R Hubbard
    0

    Robert here is a good video in the service api's

    http://stream.umbraco.org/video/9920652/master-the-service-apis

Please Sign in or register to post replies

Write your reply to:

Draft