Copied to clipboard

Flag this post as spam?

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


  • Saied 349 posts 674 karma points
    Jun 24, 2016 @ 00:41
    Saied
    0

    Assign default template depending on where a shared document is being added?

    I have 3 websites under one umbraco instance (bloga, blobb, and blogc). They all share one document type (blog), but they have 3 different templates (bloga, blogb, and blogc).

    The blog document type has the 3 templates allowed.

    If the user creates a node under site bloga, I want the default template to bloga, if the user creates a node under blogb, I want the default template to be blogb.

    Is this possible? If so, how can I achieve it.

    Thanks, Saied

  • Michaël Vanbrabandt 863 posts 3348 karma points c-trib
    Jun 24, 2016 @ 06:30
    Michaël Vanbrabandt
    0

    Hi Saied,

    I think the best way to do this is to hook into the BeforePublish event and assign a template their to your new node.

    An example of hooking into an event can be found here

    Then you can set the default template by setting the property content.ContentType.DefaultTemplate.

    Hope this helps

    /Michaël

  • Saied 349 posts 674 karma points
    Jun 24, 2016 @ 11:12
    Saied
    0

    Hi Michaël,

    I am using 7.4.3. I think the link you sent me was legacy, so I was wondering if it was the same event or called something else now.

    Also, if I can set the template like this, does this mean that if the template name changes, the event would have to be updated or does it do it some other way?

    Thanks, Saied

  • Michaël Vanbrabandt 863 posts 3348 karma points c-trib
    Jun 24, 2016 @ 11:18
    Michaël Vanbrabandt
    0

    Hi Saied,

    here is the new link for versions above 6: https://our.umbraco.org/documentation/Reference/Events/application-startup

    You can get the allowed templates available for the new node by looking at the property content.ContentType.AllowedTemplates.

    So if a template changes by name or something else this will be visible in this list.

    /Michaël

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies