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

Thread: Template Switching for Topics...

  1. #1
    bdamore is offline Member
    Join Date
    Jun 2011
    Posts
    52

    Default Template Switching for Topics...

    Hello.
    I've been reading a lot of posts in here regarding template switching and I have a few questions.

    a. How do I get the topic name/page from skinbase.cs?
    -taken from driver.aspxcs: String PN = CommonLogic.QueryStringCanBeDangerousContent("Topi cName");
    doesn't work here since (I guess) its before the page even gets to 'prerender' or 'preinit' being SkinBase.cs
    -upon adding a PreInit block to handle it, the skinbase.cs errors badly so that won't work

    b. in driver.aspx.cs: I tried adding
    Topic1.LoadTemplate("skins/Skin_1/templateMemberArea.ascx");
    but it doesn't work (I assume the template is set before this page even begins loading in SkinBase.cs

    So, how/where can I add something like:
    xxx.LoadTemplate("skins/Skin_1/templateMemberArea.ascx");
    to make a topic use a different template?

  2. #2
    bdamore is offline Member
    Join Date
    Jun 2011
    Posts
    52

    Default Solved.

    Here's what I did.
    In App_Code/SkinBase.cs I modified GetTemplateName(): (look at !!!!!)

    Code:
     private static string GetTemplateName()
            {
                string templateName = CommonLogic.QueryStringCanBeDangerousContent("template");
                //AppLogic.CheckForScriptTag(templateName);
                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");
                }
    
               
                //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
                String PN = CommonLogic.QueryStringCanBeDangerousContent("Topic");
                AppLogic.CheckForScriptTag(PN);
                if (PN.ToLower().Contains("guide")) //or anything you're looking for
                {
                    templateName = "templatememberarea";
                }
                //Don't forget, There must be a corresponding templatememberarea.ascx (or whatever you want) template file in the ‘skins/Skin_1’ folder 
                //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
        
    
                if (templateName.Length > 0 && !templateName.EndsWith(".ascx", StringComparison.InvariantCultureIgnoreCase))
                {
                    // undocumented feature:
                    templateName += ".ascx";
                }
    
                return templateName;
            }