Copied to clipboard

Flag this post as spam?

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


  • John 27 posts 49 karma points
    May 27, 2010 @ 15:41
    John
    0

    Dynamic Node Template

    Hi,

    Does anyone know how to dynamically change the template on a node?

     

    Basically my issue is I want to display a node using a different template when requested from a subdomain.

    Currently I duplicate the nodes so there would be:

    • Node A
    • Node A - A subdomain
    • Node B
    • Node B - A subdomain

    etc..

     

    However this is becoming a little unmanageable as I am looking to add some more subdomain.

    Has anyone any ideas?

     

     

  • Lee Kelleher 4020 posts 15802 karma points MVP 13x admin c-trib
    May 27, 2010 @ 16:00
    Lee Kelleher
    1

    Hi John,

    There are a few ways you could tackle this...

    1. Use the "umbracoInternalRedirectId" property to redirect (or re-use) the content from a different node. So you could set-up your sub-domains to redirect to the primary content node?

    2. Write a HttpModule to intercept the page request (before it gets to umbraco.UmbracoDefault.OnInit) and set the "altTemplate" to the template alias that you want to use.  You can do this via the HttpContext Items:

    HttpContext.Current.Items["altTemplate"] = "MyTemplateAlias";

    3. You could inherit from and replace the UmbracoDefault page class in "default.aspx" ... and put the logic to set the Template (if you know the Id) in there.

    There are many ways to tackle this... just got to choose which is best for you.

    Cheers, Lee.

    PS. It's a small world, I grew up near Wigan, in Hindley Green - but that was many years ago!

  • John 27 posts 49 karma points
    May 27, 2010 @ 17:15
    John
    0

    I'll have a look into the different solutions, thanks.

    P.S.

    It must be a very small world, I live in Hindley Green lol

  • Lachlann 344 posts 626 karma points
    Feb 17, 2011 @ 17:26
    Lachlann
    0

    Hey Lee

    Im interetested in using the option you suggested "HttpModule to intercept the page request " I am quite new to c# and I am not really sure were to start with this, could you expand a bit on the suggestion?

     

    many thanks

     

    Lachlann

Please Sign in or register to post replies

Write your reply to:

Draft