Copied to clipboard

Flag this post as spam?

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


  • Damien Green 72 posts 134 karma points
    May 03, 2016 @ 12:35
    Damien Green
    0

    Possible to get a template id by alias

    Hi Guys,

    Is it possible to get a template ID by a given template alias?

    Many thanks,

    Damien

  • Veronica Burd 76 posts 201 karma points
    May 03, 2016 @ 13:09
    Veronica Burd
    0

    I had a quick look and the FileService has a GetTemplate method with an overload that takes an alias as parameter.

     ITemplate Umbraco.Core.Services.FileService.GetTemplate(string alias)
    

    Depending on where you call this from you can access either via :

    ApplicationContext.Services.FileService
    

    OR if you're in a SurfaceController

    Services.FileService
    

    I haven't tried it myself but its worth a look - here's the link to the relevant FileService page

    Don't think there's a way to get the Id without first retrieving the template object though.

    HTH

    Ver

  • Damien Green 72 posts 134 karma points
    May 04, 2016 @ 07:49
    Damien Green
    0

    Hi Veronica,

    Thank you so much for this info, sounds like it might be exactly what I need! I'll look into it.

    All the best,

    Damien

  • 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