1-888-365-2779
+1-888-365-2779
Try Now
More in this section

Forums / Developing with Sitefinity / materpage overwrites content when switching

materpage overwrites content when switching

2 posts, 0 answered
  1. Gregory
    Gregory avatar
    25 posts
    Registered:
    16 Mar 2009
    31 Mar 2009
    Link to this post
    using the instructions and code from http://www.sitefinity.com/support/forums/support-forum-thread/b1043S-bhthmm.aspx

    I am able to switch the masterpage and theme when a mobile device is detected. The issue is that any controls put into the original masterpage in sitefinity are loaded into the new masterpage and any controls put into that masterpage disappear, this causes issues when we want to change what loads in the pda theme.

    for example
    we have the nonmobile device theme and masterpage, we put a flash animation in the template using sitefinity, that same flash animation then loads on a mobile device but it has been transferred to the other masterpage at runtime.

    The masterpages do switch I was able to test this but hardcoding some text into the pda masterpage.


    Is there a way to prevent it from loading these controls and make it load the controls we put into the pda theme/masterpage.
  2. Parvan
    Parvan avatar
    151 posts
    Registered:
    24 Sep 2012
    03 Apr 2009
    Link to this post
    Hello Gregory,

    There is one more step to do.
    You need to change the template of the page. The templates in Sitefinity contain the controls that you add through the edit template interface.
    In order to do this you will Sitefinity 3.6 Hotfix. If you are using older version please upgrade to Sitefinity 3.6 Hotfix.
    I am attaching the sample code you can use in order to change the theme, master page and the template dynamically for mobile devices. I changed only the class extending the InternalPage class.

    1. Put the DetectingPage.cs(attached in this post) to your site  App_Code folder

    2. Edit the file ~[your site]/Sitefinity/cmsentrypoint.aspx as shown below:
    <%@ Page Inherits="Telerik.Cms.Web.DetectingPage, App_Code" 
     MasterPageFile="~/Sitefinity/Dummy.master" %> 

    3. Edit the DetectingPage.cs - set the template name of you mobile master page and add the condition which checks if the client is a mobile device:
    protected bool CheckIfDeviceIsMobile() 
          //return true if device is mobile 
         // false otherwise 
     
    // here set the name of your template (you can see it at Pages->Templates in admin // menu 
    public const string TemplateNameForMobile = "Mobile"

    I hope this information will help you.

    Regards,
    Parvan
    the Telerik team

    Check out Telerik Trainer , the state of the art learning tool for Telerik products.
2 posts, 0 answered