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.
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?
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
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
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
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
is working on a reply...
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.