Copied to clipboard

Flag this post as spam?

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


  • Rune Grønkjær 1303 posts 2895 karma points
    Feb 16, 2011 @ 10:47
    Rune Grønkjær
    0

    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

  • kows 81 posts 151 karma points c-trib
    Feb 16, 2011 @ 11:27
    kows
    1

    umbraco.cms.businesslogic.template.Template.GetByAlias("MainMaster");

    might help you.

  • Rune Grønkjær 1303 posts 2895 karma points
    Feb 16, 2011 @ 13:40
    Rune Grønkjær
    0

    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

  • Rune Grønkjær 1303 posts 2895 karma points
    Feb 16, 2011 @ 13:42
    Rune Grønkjær
    0

    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

  • kows 81 posts 151 karma points c-trib
    Feb 16, 2011 @ 16:55
    kows
    0

    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?)

  • Rune Grønkjær 1303 posts 2895 karma points
    Feb 16, 2011 @ 16:57
    Rune Grønkjær
    0

    I'll take a look

    Thanks again

    /Rune

  • 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