Copied to clipboard

Flag this post as spam?

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


  • prinzie 13 posts 42 karma points
    Mar 13, 2012 @ 15:38
    prinzie
    0

    Multiple masterpage folder paths

    Hello

    It it possible to have multiple masterpage folder paths?

    We have different projects, running on one Umbraco solution:


    For each project we wish to have the masterpages separated EG: masterpage/project1 masterpage/project2 etc.

    I tried adding the following in the config. file, but it seems that umbraco is only accepting one masterpage path?    

      <add key="umbracoMasterPagesPath" value="~/masterpages/Apth/,~/masterpages/" />

     

  • Mike Chambers 636 posts 1253 karma points c-trib
    Mar 13, 2012 @ 16:25
    Mike Chambers
    0

    We approached it slightly differently and injected an override on the masterpage to be used dependant on some parameter...

    so have Default.aspx inherit from your custom...

    {%@ Page language="c#" Codebehind="default.aspx.cs" AutoEventWireup="True" Inherits="NAMESPACE.UmbracoDefault" trace="true" validateRequest="false" %}

     

            protected override void OnPreInit(EventArgs e)
            {
                base.OnPreInit(e);
    
                try
                {
                    if (String.IsNullOrEmpty(GetCurrentAltTemplateAlias()))
                    {
                        // using the admin specified template
                        Node currentNode = Node.GetCurrent();
                        umbraco.template template = new umbraco.template(currentNode.template);
    
                        // we're using the mobileesp.org to detect mobile/tablet items.
    
                            if (DetectTierTablet())
                            {
                                try
                                {
                                    if (umbraco.cms.businesslogic.template.Template.GetByAlias(template.TemplateAlias + "Tablet") != null)
                                    {
                                        Page.MasterPageFile = Page.MasterPageFile.Replace(".master", "Tablet.master");
                                    }
                                }
                                catch { }
                            }
                            else if (DetectMobileLong())
                            {
                                try
                                {
                                    if (umbraco.cms.businesslogic.template.Template.GetByAlias(template.TemplateAlias + "Mobile") != null)
                                    {
                                        Page.MasterPageFile = Page.MasterPageFile.Replace(".master", "Mobile.master");
                                    }
                                }
                                catch { }
                            }
    
                    }
                    else
                    {
    
                        // already using an alternative tempalte
                        //Response.Write(GetCurrentAltTemplateAlias() + "");
                    }
                }
                catch { }
            }
    
    
            public static string GetCurrentAltTemplateAlias()
            {
                return (System.Web.HttpContext.Current.Items["altTemplate"] ?? "").ToString();
            }
    
        }
    }
    
  • prinzie 13 posts 42 karma points
    Mar 15, 2012 @ 08:33
    prinzie
    0

    Thank you very much for your help.

  • Jigar Gala 14 posts 74 karma points
    Jun 18, 2012 @ 11:00
    Jigar Gala
    0

    Hi

    I tried to implement the solution suggested above by Mike.

    But somehow  it is giving the below error:

    Master template is the same as the current template. It would cause an endless loop! Make sure that the current template ''Template with id: '-1' has another Master Template than itself. You can change this in the template editor under 'Settings'

    Also.. if i do a...

    Response.Write(umbraco.cms.businesslogic.template.Template.GetByAlias(template.TemplateAlias + "Mobile"));

    It gives..

    { Id: 3317, Text: HomePage TemplateMobile, ParentId: -1 }

    The ParentId -1 seems to cause the issue.

     

    Any idea what is going wrong?

    Any help will be appreciated

     

    Thanks


Please Sign in or register to post replies

Write your reply to:

Draft