Important Notice from AspDotNetStorefront
It is with dismay that we report that we have been forced, through the action of hackers, to shut off write-access to this forum. We are keen to leave the wealth of material available to you for research. We have opened a new forum from which our community of users can seek help, support and advice from us and from each other. To post a new question to our community, please visit: http://forums.vortx.com
Results 1 to 9 of 9

Thread: Master Pages - Version 9

  1. #1
    fracoper is offline Junior Member
    Join Date
    Jan 2010
    Posts
    8

    Default Master Pages - Version 9

    Hi,

    In version 8 it was possible to have 1 template per locale, for example:

    template.en-US.aspx
    template.es-ES.aspx

    In version 9, using master pages, how can we customize a master page for a specific locale?

    Thanks

    Francisco

  2. #2
    George the Great is offline Senior Member
    Join Date
    Nov 2006
    Location
    Cleveland, OH
    Posts
    1,792

    Default

    Just finished adding that back in and will be in the next maintenance release (hopefully tonight...we're just cranking out tweaks as we see necessary and with all of the architectural changes we've made we're looking for some real-world feedback). For now if you need to add it back in you can modify App_Code/SkinBase.cs in the GetTemplateName method
    Code:
    /// <summary>
    /// Determines which masterpage skin to use to render the site to the browsing customer
    /// </summary>
    /// <returns>The name of the file that is the masterpage</returns>
    private string GetTemplateName()
    {
        String templateName = String.Empty;
    
        m_ismobile = HttpContext.Current.Request.Browser.IsMobileDevice || CheckUserAgentForMobile;
    
        templateName = CommonLogic.QueryStringCanBeDangerousContent("template");
    
        if (templateName == null || templateName.Length == 0)
        {
            // undocumented feature:
            templateName = AppLogic.AppConfig("Template" + CommonLogic.GetThisPageName(false));
        }
        if (templateName == null || templateName.Length == 0)
        {
            templateName = CommonLogic.IIF(AppLogic.ProductIsMLExpress() && !AppLogic.IsAdminSite, "expressTemplate", "template");
        }
    
        // when OverrideTemplate is overridden in a page that inherits from SkinBase, the value returned there will be
        // the value assigned here
        templateName = OverrideTemplate();
    
        // sanity check to ensure that OverrideTemplate wasn't overridden in a page and
        // then set to an empty string
        if (templateName.Trim().Length == 0 || !CommonLogic.FileExists(SkinRoot + templateName))
        {
            if (m_ismobile)
            {
                templateName = "mobile_template.master";
            }
            else
            {
                templateName = "template.master";
            }
        }
    
        // only start looking for localized masterpages if the GlobalConfig AllowTemplateSwitchingByLocale
        // is set to true, so we don't unnecessarily check for multiple files on every page load
        if (AppLogic.GlobalConfigBool("AllowTemplateSwitchingByLocale"))
        {
            String templateLocaleName = null;
            String _url = String.Empty;
            
            // try customer locale:
            templateLocaleName = templateName.Replace(".master", "." + ThisCustomer.LocaleSetting + ".master");
            _url = Path.Combine(SkinRoot, templateLocaleName);
            m_TemplateFN = CommonLogic.SafeMapPath(_url);
    
            // if the file doesn't exist, check the default locale
            if (!CommonLogic.FileExists(m_TemplateFN))
            {
                // try default store locale path:
                templateLocaleName = templateName.Replace(".master", "." + Localization.GetWebConfigLocale() + ".master");
                _url = Path.Combine(SkinRoot, templateLocaleName);
                m_TemplateFN = CommonLogic.SafeMapPath(_url);
            }
    
            // if we found a locale match, use the name of the localized masterpage
            if (CommonLogic.FileExists(m_TemplateFN))
            {
                templateName = templateLocaleName;
            }
        }
    
        m_TemplateName = templateName;
    
        return templateName;
    }
    and then create a global config parameter called AllowTemplateSwitchingByLocale and set it to true
    Code:
    INSERT GlobalConfig([Name], [GroupName], [Description], [ConfigValue], ValueType) VALUES('AllowTemplateSwitchingByLocale', 'DISPLAY', 'Indicator of whether the site should attempt to load different masterpage skins based on the current locale of the browsing customer.  This should only be enabled if you have multiple locales and have created different masterpages for each of your locales (eg. template.en-us.master, template.en-gb.master, etc...).  Enabling this when you do not have multiple locales or when you have not created multiple masterpages that vary by locale can hinder the performance of your site.', 'true', 'boolean')
    <a href="http://www.aspdotnetstorefront.com">Shopping Cart Software</a>

  3. #3
    hosteddesign is offline Junior Member
    Join Date
    Mar 2010
    Posts
    3

    Exclamation locale template switching format

    I have just download the newest skinbase.cs from the '3 release.
    I have not however changed the webconfig as I noticed this release had not differences to the '2 release.

    I also publish my site www.hosteddesign.com.au in english, japanese, chinese traditional and simplified.

    The locales are working well however the template switching is not working.

    What should I be calling the various locale master pages as?
    template.jp-JP.master etc??


    Thanks

  4. #4
    AspDotNetStorefront Staff - Scott's Avatar
    AspDotNetStorefront Staff - Scott is offline Administrator
    Join Date
    Mar 2007
    Location
    Ashland, OR
    Posts
    2,390

    Default

    That's the correct format, yes. Those .master files should all go in the App_Templates/Skin_# folder for the skin you're using.

  5. #5
    avsune is offline Member
    Join Date
    Feb 2008
    Posts
    68

    Default

    how do I get the pagename in the template.master I want to add some conditional navigation (if it s on a certain page it should be there ) Is it possible?

  6. #6
    ASPAlfred is offline Senior Member
    Join Date
    Nov 2007
    Posts
    2,244

    Default

    Use the method CommonLogic.GetThisPageName(false).

  7. #7
    yakatz is offline Member
    Join Date
    Jul 2008
    Location
    Could be anywhere between 60N-28N and 77W-36E
    Posts
    84

    Default

    Quote Originally Posted by AspDotNetStorefront Staff - George View Post
    Just finished adding that back in and will be in the next maintenance release (hopefully tonight...we're just cranking out tweaks as we see necessary and with all of the architectural changes we've made we're looking for some real-world feedback).
    Are these changes making it to multistore?
    Using ASPDotNetStoreFront since Version 3
    Got Version 9.
    Almost ready to deploy MultiStore (final testing stages for the new FirstData gateway)
    Finally upgraded our server to 2008 R2.

  8. #8
    avsune is offline Member
    Join Date
    Feb 2008
    Posts
    68

    Default

    CommonLogic.GetThisPageName(false) gives me the seo friendly url I want the name of the page executed like showproduct.aspx how do I get that?

  9. #9
    mitul.modi is offline Junior Member
    Join Date
    Nov 2010
    Posts
    1

    Question access master page variable.

    How to access any control variable of master page..?
    e.g. I declare
    <a id="aHome" runat="server" href="default.aspx">HOME</a>
    How do u access this anchor tag.