Copied to clipboard

Flag this post as spam?

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


  • Carlos 338 posts 472 karma points
    Feb 17, 2011 @ 17:49
    Carlos
    0

    Get alternate template ID in XSLT

    This should be easy. How do you get the Alternate Template ID of the current Node in XSLT?

    Does the doc type of the normal template need to also have the AltTemplate tied to it?

    Thanks. 

  • Daniel Bardi 927 posts 2562 karma points
    Feb 17, 2011 @ 19:29
    Daniel Bardi
    0

    Pull the querystring 

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

  • Kim Andersen 1447 posts 2196 karma points MVP
    Feb 18, 2011 @ 21:21
    Kim Andersen
    0

    Hi Carlos

    How does the URL of the page look? Which of these two:

    domain.com/page.aspx?alttemplate=alternateTemplate

    domain.com/page/alternateTemplate.aspx

    ?

    /Kim A

  • Carlos 338 posts 472 karma points
    Feb 21, 2011 @ 18:47
    Carlos
    0

    @Kim,

    I tried Daniel's solution. Still couldn't get the template.

    HOWEVER, this is the way we are applying the template.

    We are using inline C# in the template by way of the <script> tag. We are using 
    string strUserAgent = Request.UserAgent.ToString().ToLower()

    and

     Request.Browser.IsMobileDevice = true || strUserAgent.Contains("iphone")

     

    To get our user agents then we are tacking on the alt template path after we get the agent.  www.domain/my-page/alternateTemplate

    This is our issue, because we are doing it dynamically-ish. 
    Since we have multiple Alternate Templates (mobile templates) we are allowing content authors choose the needed alternate template. 

    I know we can tie the alternate template to our document types which is what we have done.  But don't know if this is going to work the way we have our alternate template system set up using C# to tack on the alternate template.

    What we are trying to do is get the alternate template for the page and if a template is template1 then choose template1 header if is template2 then choose template2 header. We want to have the least amount of Templates and macros as possible so setting one macro in each of the templates would be the ultimate goal, instead of having the manage a bunch of macros.

    Any suggestions would be awesome. But now that I think about it, we may not be able to do it the way we want to since we are sniffing the agent then adding the alternate template. 

     

Please Sign in or register to post replies

Write your reply to:

Draft