Copied to clipboard

Flag this post as spam?

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


  • Hamish 96 posts 154 karma points
    Oct 07, 2009 @ 01:06
    Hamish
    1

    How to get the Template ID of the Rendered Alternate Template

    I'm trying to use the Alternate template method but am unable to get the id of the template that is being rendered. I have a product and it has relations to recipes.

    I have a template with the alias "Related-Recipes" which can be thrown onto the end of the product url to display the related recipes. For example:

    Product Information
    /products/product-info.aspx

    Product Related List
    /products/product-info/related-recipes.aspx (simply uses the same info as Product Information but using the Related Recipes template)

    However I am trying to identify the template that is being used to adjust the breadcrumbs accordingly to allow the user to navigate back one step. Ideally I would like to avoid using query strings.

    I tried using the solution from the following link but this only give the current nodes template id/alias but not the rendered template id/alias:
    http://our.umbraco.org/forum/developers/xslt/1764-testing-against-active-template-name-%5Bsolved%5D

    Has anyone dealt with this scenario before or can give a possible solution?

  • Masood Afzal 176 posts 522 karma points
    Oct 07, 2009 @ 01:20
    Masood Afzal
    0

    Have you tried something like this:

     

    Node currentNode = Node.GetCurrent();
    // currentNode.template


  • Hamish 96 posts 154 karma points
    Oct 07, 2009 @ 02:24
    Hamish
    0

    Thats getting the current nodes set template - not the alternate template that has been added to the end of the url

  • Murray Roke 503 posts 966 karma points c-trib
    Oct 07, 2009 @ 02:58
    Murray Roke
    1

    This will get what you need

    public static string GetCurrentAltTemplateAlias()
    {
    return (HttpContext.Current.Items["altTemplate"]??"").ToString();
    }
  • Hamish 96 posts 154 karma points
    Oct 07, 2009 @ 03:01
    Hamish
    0

    Awesome - it returned the alternate template alias name - perfect for checking in the xslt

  • Hamish 96 posts 154 karma points
    Oct 07, 2009 @ 03:02
    Hamish
    0

    Thanks Murray ;)

Please Sign in or register to post replies

Write your reply to:

Draft