Copied to clipboard

Flag this post as spam?

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


  • Lachlann 343 posts 625 karma points
    Feb 18, 2011 @ 16:39
    Lachlann
    0

    Dynamicaly Choose Page Template

    Hey All,

    Is there a way to dynamicaly choose which template a page renders without having to resort to using the altTemplate query string?

    L

  • Jan Skovgaard 11258 posts 23500 karma points MVP 7x admin c-trib
    Feb 18, 2011 @ 19:14
    Jan Skovgaard
    0

    Hi Lachlann

    I'm not sure if there are other options than using the altTemplate...but could you make a little description of the scenario where you are in need of this? Maybe it's more easy to give you advice then :-)

    /Jan

  • Lachlann 343 posts 625 karma points
    Feb 21, 2011 @ 10:52
    Lachlann
    0

    Hi Jan,

     

    I have reapproached the problem and perhaps using altTemapltes via the url i.e. mysite.com/about/mytemplate.aspx rather than mysite.com/about.aspx?altTemplate=mytemplate would be okay. However my problem now is how to detect which tempalte is being used. If i use

    var t = new umbraco.template(currentPage.template);

    this just returns the default tempalte for the page not the tempalte currently being used to render the page. So I have no way to detect which template is currently being used to render the page, this means that if a desktop browser trys to access a mobile url I have no way to redirect them to the web version.

    does that make sense.

     

    thanks for your help

     

    L

  • Lachlann 343 posts 625 karma points
    Feb 21, 2011 @ 10:59
    Lachlann
    0

    Okay, just after i posted this i found this post

    http://our.umbraco.org/forum/templating/templates-and-document-types/4506-How-to-get-the-Template-ID-of-the-Rendered-Alternate-Template

    this lets me get the name of the altTemplate if it is used.

     

    L

  • Lachlann 343 posts 625 karma points
    Feb 21, 2011 @ 11:01
    Lachlann
    0

    Okay, just after i posted this i found this post

    http://our.umbraco.org/forum/templating/templates-and-document-types/4506-How-to-get-the-Template-ID-of-the-Rendered-Alternate-Template

    this lets me get the name of the altTemplate if it is used.

     

    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