Copied to clipboard

Flag this post as spam?

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


  • Kevin Farrow 46 posts 67 karma points
    Mar 08, 2010 @ 17:55
    Kevin Farrow
    0

    Find the AltTemplate in use

    We have a page with a number of tabs used as links. Each link opens an alternate template for that page i.e.

    <ul>

    <li><a href="ProductX/TemplateA>Order Details</a></li>

    <li><a href="ProductX/TemplateB">Order Lines</a></li>

    <li><a href="ProductX/TemplateC">Other Details</a></li>

    </ul>

    I am using XSLT to render the above and need to set class="active" on the <li> for the page selected.

    My problem is that I need to know which alternative template was used when the page loads. I tried using $currentPage/@tempate but that only returns the template associated with the page. I need something like $currentPage/@templateInUse :-)

    Is there a way to get the template that is being used from with my XSLT ?

    Thanks for any help,

  • Lee Kelleher 4026 posts 15836 karma points MVP 13x admin c-trib
    Mar 08, 2010 @ 18:39
    Lee Kelleher
    0

    Hi RDNZL,

    You can find out the name/alias of the template from the "altTemplate" property which is stored in a HttpContext Item:

    <xsl:value-of select="umbraco.library:GetHttpItem('altTemplate')" />

    The only problem is that this doesn't give you the template's ID, just it's name/alias.

    If I figure out how to get the ID, I'll let you know.

    Cheers, Lee.

  • Kevin Farrow 46 posts 67 karma points
    Mar 08, 2010 @ 22:59
    Kevin Farrow
    0

    Thanks Lee,

    That worked a treat :-)

    Kind Regards,
    RDNZL

  • Murray Roke 503 posts 966 karma points c-trib
    Aug 20, 2013 @ 23:15
    Murray Roke
    0

    We wrote a method that doesn't seem to work in 4.11.8 , I think it worked in earlier versions.

    public static string GetCurrentAltTemplateAlias()
    {
        return (HttpContext.Current.Items["altTemplate"] ?? "").ToString();
    }
    
Please Sign in or register to post replies

Write your reply to:

Draft