Copied to clipboard

Flag this post as spam?

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


  • Bo Damgaard Mortensen 712 posts 1189 karma points
    Apr 22, 2013 @ 13:34
    Bo Damgaard Mortensen
    0

    Using a template under multiple masterpages

    Hi all,

    I'm having a bit of troule figuring this one out :-) I have an Umbraco installation which contains two different types of sites which have different layouts. Both sites contains a news section and I'm using the same News list document type/template and News document type/template for this. Consider the following document type structure:

    - Site 1
    - Site 1 textpage
    
    - Site 2
    - Site 2 textpage
    
    - News
          - News item

    Which leads to the following structure in the content tree:

    - Site 1
          - Textpage 1
          - News
                - News item 1
    
    - Site 2
          - Textpage 1
          - News
                - News item 1

    The template structure then looks like this:

    - Site 1 master
           - Site 1 textpage
           - News
           - News item
    
    - Site 2 master
           - Site 2 textpage
           - <News template should also be here>
           - <News item template should also be here>

    Since the News and News item templates are already using the Site 1 master template, they cannot use the Site 2 master template.

    Is there any way of doing this without any obscure hacks? ;-)

    Thanks a lot in advance.

    - Bo

  • Rich Green 2246 posts 4006 karma points
    Apr 22, 2013 @ 14:12
    Rich Green
    0

    Hey Bo,

    I'm pretty sure there's a simple few lines of .NET that can swap out Master Templates before the template gets rendered, it was part of the Umbraco/technet talk at codegarden a while back.

    Can't remember if the code ever got posted but remember it was pretty simple, hope that helps, sorry I don't have the code!

    Rich

     

  • Rich Green 2246 posts 4006 karma points
    Apr 22, 2013 @ 14:14
    Rich Green
    0

    Quick google found this:

     

    protected void Page_PreInit(object sender, EventArgs e) 
    { 
     if () //check home node ID or simular     this.Page.MasterPageFile = "~/Site1.master";
     else
        this.Page.MasterPageFile = "~/Site2.master";
    }
    Rich

     

  • Rich Green 2246 posts 4006 karma points
    Apr 22, 2013 @ 14:15
    Rich Green
    0

    protectedvoidPage_PreInit(object sender,EventArgs e) 

    {  if()//logic to check which site is being called

    this.Page.MasterPageFile = "~/Site1.master";

     else

        this.Page.MasterPageFile="~/Site2.master";

    }

  • Rich Green 2246 posts 4006 karma points
    Apr 22, 2013 @ 14:16
  • Bo Damgaard Mortensen 712 posts 1189 karma points
    Apr 22, 2013 @ 14:25
    Bo Damgaard Mortensen
    0

    Hi Rich,

    Thanks a lot for your input :-) That could very well be the solution! I'll have to fool around a bit with it. Guess you have to make sure that the contentplaceholder match then.

    I'll try it out and then get back to this post. Thanks again!

    - Bo

  • 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