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 24 of 24

Thread: Master Pages Template Switching

  1. #1
    ssgumby is offline Senior Member
    Join Date
    Feb 2009
    Posts
    683

    Default Master Pages Template Switching

    WIll this still work? So say I can setup a look for home page, product detail and product pages? Currently in 8.0.1.2 I have three separate templates.

  2. #2
    mbertulli is offline Senior Member
    Join Date
    Aug 2008
    Posts
    243

    Default

    So far it looks like it does. We're working on the home page template right now for a new site, and we have a standard template.master as well.

    Will be implementing a product.master shortly and will post if we encounter any problems.
    Matthew Bertulli
    Demac Media
    mbertulli@demacmedia.com
    Custom Web Design & E-Commerce Development
    AspDotNetStoreFront Platinum DevNet Partner
    ----

    Custom Skinning & Design
    Web Services Integration
    Custom Reporting
    Salesforce.com eCommerce AspDotNetStoreFront Integration

  3. #3
    ssgumby is offline Senior Member
    Join Date
    Feb 2009
    Posts
    683

    Default

    Cool thanks. I am apparently a little behind you

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

    Default

    Yep..."template" switching (we're going with masterpage skins as the terminology for now...just to keep an essence of familiarity with the design aspect) is functional, as are home templates. I also just made a post about locale template switching here in this thread
    <a href="http://www.aspdotnetstorefront.com">Shopping Cart Software</a>

  5. #5
    mbertulli is offline Senior Member
    Join Date
    Aug 2008
    Posts
    243

    Post

    George,

    It seems as though the SkinBase.cs logic for "template switching" isn't working as the v8 was. From what I can see through debugging, the following is where the detection of the appropriately named AppConfig param is detected based on page name: (around line 190)

    // undocumented feature:
    templateName = AppLogic.AppConfig("Template" + CommonLogic.GetThisPageName(false));
    It appears that CommonLogic.GetThisPageName returned the ShowProduct.aspx in v8, but in v9 it returns the rewritten URL (i.e. p-1-product.aspx).

    So right now, in v9, specifying an AppConfig of TemplateShowProduct.aspx does not result in the appropriate Master page file being loaded.
    Matthew Bertulli
    Demac Media
    mbertulli@demacmedia.com
    Custom Web Design & E-Commerce Development
    AspDotNetStoreFront Platinum DevNet Partner
    ----

    Custom Skinning & Design
    Web Services Integration
    Custom Reporting
    Salesforce.com eCommerce AspDotNetStoreFront Integration

  6. #6
    DanV's Avatar
    DanV is offline Ursus arctos horribilis
    Join Date
    Apr 2006
    Posts
    1,568

    Default

    Matt,

    Does adding the rewritten URL to the appconfig resolve the issue? This is a result of changing over to the ASP.NET Routing engine for URL Rewrites.

    - Dan

  7. #7
    mbertulli is offline Senior Member
    Join Date
    Aug 2008
    Posts
    243

    Default

    Adding the re-written URL to the AppConfig does resolve the issue, but doesn't really help the business-case for broad based Product, Category, Manufacturer Templating (or in v9, lack there of).

    It's not really plausible to have to specify a template per product, or per category. Most sites we've built have a product template, category template, home template, and checkout process template.

    I might just modify SkinBase to add some extra logic that would bring back the needed functionality.
    Matthew Bertulli
    Demac Media
    mbertulli@demacmedia.com
    Custom Web Design & E-Commerce Development
    AspDotNetStoreFront Platinum DevNet Partner
    ----

    Custom Skinning & Design
    Web Services Integration
    Custom Reporting
    Salesforce.com eCommerce AspDotNetStoreFront Integration

  8. #8
    ssgumby is offline Senior Member
    Join Date
    Feb 2009
    Posts
    683

    Default

    So I guess we are saying template switching does not work? Yikes

  9. #9
    mbertulli is offline Senior Member
    Join Date
    Aug 2008
    Posts
    243

    Default

    I think with a few lines of code in the SkinBase.cs file, it can be re-enabled quite easily.

    We're playing with this right now. Will post an update shortly.
    Matthew Bertulli
    Demac Media
    mbertulli@demacmedia.com
    Custom Web Design & E-Commerce Development
    AspDotNetStoreFront Platinum DevNet Partner
    ----

    Custom Skinning & Design
    Web Services Integration
    Custom Reporting
    Salesforce.com eCommerce AspDotNetStoreFront Integration

  10. #10
    DanV's Avatar
    DanV is offline Ursus arctos horribilis
    Join Date
    Apr 2006
    Posts
    1,568

    Default

    Template switching works fine. The URL format is different however, so you need to create an appconfig such as TemplateP-11-myproduct.aspx and assign the template there, instead of showproduct.aspx.

    We have a discussion item in to support both methods, however the upside to the current implementation is that it gives a much greater degree of flexibility (you could have a masterpage for each product if you wanted).

    You can also re-enable the old way by going into showproduct.aspx and in the Page PreInit event, just set Page.MasterPageFile = "~/App_Templates/Skin_1/custom.master"; and the page will use that file.

    - Dan

  11. #11
    ssgumby is offline Senior Member
    Join Date
    Feb 2009
    Posts
    683

    Default

    Quote Originally Posted by AspDotNetStorefront - Dan View Post
    Template switching works fine. The URL format is different however, so you need to create an appconfig such as TemplateP-11-myproduct.aspx and assign the template there, instead of showproduct.aspx.

    We have a discussion item in to support both methods, however the upside to the current implementation is that it gives a much greater degree of flexibility (you could have a masterpage for each product if you wanted).

    You can also re-enable the old way by going into showproduct.aspx and in the Page PreInit event, just set Page.MasterPageFile = "~/App_Templates/Skin_1/custom.master"; and the page will use that file.

    - Dan
    With over 1000 products, I think I will pass on the TemplateP-NN-myproduct.aspx

    I like your other option better, and i'd like to see what Matt comes up with.

  12. #12
    storedeveloper is offline Member
    Join Date
    May 2009
    Posts
    77

    Default Hi

    Any progress for template switching ??

  13. #13
    storedeveloper is offline Member
    Join Date
    May 2009
    Posts
    77

    Default Hi

    I have done with template switching for the master pages. I modified some code in the skinbase .cs. Now i am able to make templates for the product, category , section and other pages like (For category i am using CategoryTemplate.master etc).

    If any one want this then please email to info@silexsoftwares.com

  14. #14
    mbertulli is offline Senior Member
    Join Date
    Aug 2008
    Posts
    243

    Default

    ssgumby,

    We just added the following to our showproduct.aspx.cs "OverrideTemplate" member.

    //DEMAC
    if (!string.IsNullOrEmpty(AppLogic.AppConfig("Templat eShowProduct.aspx").ToString()))
    HT = AppLogic.AppConfig("TemplateShowProduct.aspx").ToS tring();
    Basically did this for showproduct, showcategory, and showsection.
    Matthew Bertulli
    Demac Media
    mbertulli@demacmedia.com
    Custom Web Design & E-Commerce Development
    AspDotNetStoreFront Platinum DevNet Partner
    ----

    Custom Skinning & Design
    Web Services Integration
    Custom Reporting
    Salesforce.com eCommerce AspDotNetStoreFront Integration

  15. #15
    jjdunkel is offline Member
    Join Date
    Jan 2006
    Location
    Chicago
    Posts
    78

    Default

    Quote Originally Posted by AspDotNetStorefront - Dan View Post
    Template switching works fine. The URL format is different however, so you need to create an appconfig such as TemplateP-11-myproduct.aspx and assign the template there, instead of showproduct.aspx.

    We have a discussion item in to support both methods, however the upside to the current implementation is that it gives a much greater degree of flexibility (you could have a masterpage for each product if you wanted).

    You can also re-enable the old way by going into showproduct.aspx and in the Page PreInit event, just set Page.MasterPageFile = "~/App_Templates/Skin_1/custom.master"; and the page will use that file.

    - Dan
    Do people seriously use this cart with a number of products low enough to do it this way? Talking about a daunting task of creating all the appconfigs...and wouldn't that make the cache get astronomically large and slow if done this way?

    This would be a good way for templating topics...but would probably still make more sense to add a template reference to each topic for ease of administration.

    I can do customizations to make the functionality work...but i'd rather have it done in the distribution so it's an easier upgrade path each time.

    Thanks for your consideration.

  16. #16
    ssgumby is offline Senior Member
    Join Date
    Feb 2009
    Posts
    683

    Default

    I totally agree jjdunkel

    The template switching was a huge factor in the convenience of this cart, and yes I can make code changes like Matt did (thanks Matt!) but it would be nice to be built in.

  17. #17
    jjdunkel is offline Member
    Join Date
    Jan 2006
    Location
    Chicago
    Posts
    78

    Default

    The Template Switching doesn't seem to be working AT ALL for me in 9.0.1.2 unless i add the following to the codebehind of the page i'm trying to template.

    For instance for it to work for topics i had to add this to driver.aspx.cs

    and an appconfig for the topic "history": name="Templatet-history.aspx" value="company.master"


    I see some language in skinbase.cs, but it's not working without adding the below code to each file.



    Code:
            protected override string OverrideTemplate()
            {
                String TemplateName = AppLogic.AppConfig("Template" + CommonLogic.GetThisPageName(false));
    
                if (TemplateName.Trim().Length == 0)
                {
                    TemplateName = "template";
                }
    
                if (base.IsMobile)
                {
                    TemplateName = "mobile_" + TemplateName;
                }
    
                if (TemplateName.EndsWith(".ascx"))
                {
                    TemplateName = TemplateName.Replace(".ascx", ".master");
                }
    
                if (!TemplateName.EndsWith(".master", StringComparison.OrdinalIgnoreCase))
                {
                    TemplateName = TemplateName + ".master";
                }
    
                if (!CommonLogic.FileExists(CommonLogic.SafeMapPath("~/App_Templates/" + CommonLogic.IIF(base.IsMobile, "MobileSkin_", "Skin_") + base.SkinID.ToString() + "/" + TemplateName)))
                {
                    TemplateName = CommonLogic.IIF(base.IsMobile, "mobiletemplate.master", "template.master");
                }
    
                return TemplateName;
            }

  18. #18
    John Morrison is offline Junior Member
    Join Date
    Sep 2008
    Posts
    20

    Default

    For what it is worth, rather then having to specify in each masterpage file in the directive as well as the code behind, we added this little mod to the skinbase.cs: replacing the original:
    C#/VB.NET Code:
                        this.MasterPageFile "~/App_Templates/" SkinDirectory "/" m_TemplateName;
                        
    this.Theme PageTheme
    With this:

    C#/VB.NET Code:
    // If this.MasterPageFile is not the out of the box skin_1/template.master then the develper said what one he/she wants to use. so dont override it .. ever..
                    
    if (String.IsNullOrEmpty(this.MasterPageFile) || this.MasterPageFile.ToLower() == "~/app_templates/skin_1/template.master" || IsMobile)
                    {
                        
    this.MasterPageFile "~/App_Templates/" SkinDirectory "/" m_TemplateName;
                        
    this.Theme PageTheme;
                    }
                    else
                    {
                        
    String[] masterPageFile this.MasterPageFile.Split('/');
                        
    m_TemplateName masterPageFile[masterPageFile.Length-1];
                        
    this.Theme masterPageFile[masterPageFile.Length 2];
                    } 
    This way if you have taken the time to specify the MaterPageFile="~/App_Templates/Skin_99/MyCustomTemplate.master" the skin base will honor it.

    The only side effect is that you can only do DYNAMIC template switching when the MasterPageFile= Directive is set to what aspdnsf uses out of the box "~/App_Templates/Skin_1/template.master"

  19. #19
    snowy is offline Senior Member
    Join Date
    Jan 2009
    Posts
    148

    Default

    Hi I am using version 8.0.1.2 and I would like to move the site to version 9.0.1.3.

    I am currently using TemplateSwitching for everything Categories , product page etc.
    and I would like to using it but I don't understand how master pages works yet.

    Are masterpages replacing template.ascx?

    How can I replicate the templateSwitching below with masterpages in version9.0.1.3?

    templatecheckoutanon.aspx ----> templatenoleftmenu_admin.ascx


    I hope someone can help me

    Thank you

  20. #20
    snowy is offline Senior Member
    Join Date
    Jan 2009
    Posts
    148

    Default

    Hi

    I have just tried to apply template switching with one categories but is not working.

    I am entering the new template below in the categories Use Skin Template: field but the template master is not switched.

    template.master_nomenu.master

    am doing something wrong?

    Thank you

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

    Default

    That won't work out of the box in 9.0.1.3. If you contact support we can send you an update that'll fix that.

  22. #22
    snowy is offline Senior Member
    Join Date
    Jan 2009
    Posts
    148

    Default

    Thank you Scott !

  23. #23
    cjbarth is offline Senior Member
    Join Date
    Oct 2008
    Posts
    392

    Default

    Quote Originally Posted by jjdunkel View Post
    The Template Switching doesn't seem to be working AT ALL for me in 9.0.1.2 unless i add the following to the codebehind of the page i'm trying to template.

    For instance for it to work for topics i had to add this to driver.aspx.cs

    and an appconfig for the topic "history": name="Templatet-history.aspx" value="company.master"


    I see some language in skinbase.cs, but it's not working without adding the below code to each file.
    You can put the same code inside of the OverrideTempate function in App_Code/SkinBase.vb. Then you'll only have to put the code in once.

  24. #24
    jjdunkel is offline Member
    Join Date
    Jan 2006
    Location
    Chicago
    Posts
    78

    Default

    Did this get addressed at all in 9.0.1.3? I haven't seen a change log for that version yet.

    And thanks for the suggestion cjbarth