Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
Hi,
How do I get a specific Master template when I do NOT know the ID. I know the name of the name and alias of the template e.g. "MainMaster".
The template object constructor have two overloads:new umbraco.template(int templateID)new umbraco.template(string templateContent)
They don't help me. Can any of you?
Thanks/Rune
umbraco.cms.businesslogic.template.Template.GetByAlias("MainMaster");
might help you.
Did'nt work for me, but you led me in the right direction. Heres my final (ugly) solution.
IEnumerable<umbraco.cms.businesslogic.template.Template> templates = umbraco.cms.businesslogic.template.Template.GetAllAsList();document.Template = templates.Single( t => t.Alias.Equals( "MainMaster" ) ).Id;
Thanks kows
/Rune
By the way. Don't know why it didn't work. It just returned 0. Maybe because I tried to fetch a tempate further down the tree!?
I never used it myself before, just had a quick search and happy it got you in the right direction.
(there's also a getidbyalias method, maybe that one returns smth without having to do your workaround?)
I'll take a look
Thanks again
is working on a reply...
Write your reply to:
Upload image
Image will be uploaded when post is submitted
How do I get a specific template?
Hi,
How do I get a specific Master template when I do NOT know the ID. I know the name of the name and alias of the template e.g. "MainMaster".
The template object constructor have two overloads:
new umbraco.template(int templateID)
new umbraco.template(string templateContent)
They don't help me. Can any of you?
Thanks
/Rune
umbraco.cms.businesslogic.template.Template.GetByAlias("MainMaster");
might help you.
Did'nt work for me, but you led me in the right direction. Heres my final (ugly) solution.
IEnumerable<umbraco.cms.businesslogic.template.Template> templates = umbraco.cms.businesslogic.template.Template.GetAllAsList();
document.Template = templates.Single( t => t.Alias.Equals( "MainMaster" ) ).Id;
Thanks kows
/Rune
By the way. Don't know why it didn't work. It just returned 0. Maybe because I tried to fetch a tempate further down the tree!?
/Rune
I never used it myself before, just had a quick search and happy it got you in the right direction.
(there's also a getidbyalias method, maybe that one returns smth without having to do your workaround?)
I'll take a look
Thanks again
/Rune
is working on a reply...