Try Now
More in this section

Forums / Designing with Sitefinity / Mobile friendly site.

Mobile friendly site.

9 posts, 0 answered
  1. Gregory
    Gregory avatar
    25 posts
    16 Mar 2009
    17 Mar 2009
    Link to this post
    We are looking to have a site that supports a Mobile device friendly look for those who visit while on Iphones, blackberries, pdas and the like. There are a couple possibilities for doing this. We want content to be identical and not to have to update every page twice (2 separate versions).

    Question 1:

    One possible way is to have a separate masterpage and switch to it based on an if statement. I came across this post http://www.sitefinity.com/support/forums/support-forum-thread/b1043S-btkaka.aspx

    unfortunately the link in it doesn't work.

    Now assuming the mobile device can be detected (which I believe it can) and we put an if statement into the masterpage to have it switch to a different layout when a mobile device is used while loading the same content. How exactly would we do this? I already have the code for detecting the mobile device I just need to know how to switch masterpages.

    Question 2:
    Another thing is my client would like to have anyone that goes to pda.sitename.com instead of www.sitename.com load the pda masterpage as well in case the detection doesn't work. I watched the URL rewriting webinar in case that would be useful but it didn't seem to have what I was looking for (I was thinking of having the pda.sitename.com be automatically rewritten to www.sitename.com/page1.aspx?pda=true for example and then use the same switch) the problem being I would need this to trigger for everypage.

    Question 3:

    Another possibility I thought of was to create a page that would be a mirror for the site and would load the content from it and put it into the different template/masterpage. Sort of streaming the content from www.sitename.com to pda.sitename.com so that any update would happen automatically but I have no idea whatsoever how to do this. If anyone has any suggestions I would really appreciate it.

    Sorry to ask so many questions at once but they were all related and I figured it would help give the picture of what I'm asking for.
  2. Gregory
    Gregory avatar
    25 posts
    16 Mar 2009
    17 Mar 2009
    Link to this post
    in case it may be useful to anyone else this is the detection code, it worked on a windows pocketpc emulator, blackberry emulator, an Iphone emulator and a generic phone emulator from openwave.


    1 using System;  
    2 using System.Configuration;  
    3 using System.Data;  
    4 using System.Web;  
    5 using System.Web.Security;  
    6 using System.Web.UI;  
    7 using System.Web.UI.HtmlControls;  
    8 using System.Web.UI.WebControls;  
    9 using System.Web.UI.WebControls.WebParts;  
    11 public partial class _Default : System.Web.UI.Page   
    12 {  
    13     protected void Page_Load(object sender, EventArgs e)  
    14     {  
    15         System.Web.HttpBrowserCapabilities browser = Request.Browser;  
    16        // Declare a boolean variable for mobile browser  
    17         bool IsMobi = false;  
    19         System.Web.HttpBrowserCapabilities myBrowserCaps = Request.Browser;  
    20         if (((System.Web.Configuration.HttpCapabilitiesBase)myBrowserCaps).IsMobileDevice)  
    21         {  
    22             IsMobi = true;  
    23         }  
    24         if (Request.Headers["X-Wap-Profile"] != null)  
    25         {  
    26             if (Request.Headers["X-Wap-Profile"].ToString().Length > 0)  
    27             {  
    28                 IsMobi = true;  
    29             }  
    30             else if (Request.Headers["X-Wap-Profile:"].ToString().Length > 0)  
    31             {  
    32                 IsMobi = true;  
    33             }  
    34             else if (Request.Headers["Profile"].ToString().Length > 0)  
    35             {  
    36                 IsMobi = true;  
    37             }  
    38             else if (Request.Headers["Profile:"].ToString().Length > 0)  
    39             {  
    40                 IsMobi = true;  
    41             }  
    42         }  
    44         bool iphonetest = false;  
    45         iphonetest = (Request.UserAgent.IndexOf("iPhone;") != -1);  
    46         if (iphonetest)  
    47         {  
    48             IsMobi = true;  
    49         }  
    51         if (IsMobi == true)  
    52         {  
    53             Label1.Text = "This is a mobile device";  
    54         }  
    55         else  
    56         {  
    57             Label1.Text = "This is not a mobile device";  
    58         }  
    60     }  
    61 }  
  3. SelAromDotNet
    SelAromDotNet avatar
    912 posts
    18 Jul 2012
    17 Mar 2009
    Link to this post
    try this link: http://www.sitefinity.com/support/forums/support-forum-thread/b1043S-babchd.aspx

    in case for whatever reason it doesn't work let me summarize, I'm using the wurfl library from http://wurfl.sourceforge.net/ that basically wraps the mobile detection methods that are outlined above. using this library, you can issue a simple query for moblie capabilities and the system will perform all necessary instructions to return the device capabilities. This will allow you to change the master page and theme during the PreInit phase of the page cycle:

    using System;     
    using System.Data;     
    using System.Configuration;     
    using System.Web;     
    using System.Web.Security;     
    using System.Web.UI;     
    using System.Web.UI.HtmlControls;     
    using System.Web.UI.WebControls;     
    using System.Web.UI.WebControls.WebParts;     
    /// <summary>     
    /// Summary description for DetectingPage     
    /// </summary>     
    public class DetectingPage : Telerik.Cms.Web.InternalPage     
        protected override void OnPreInit(EventArgs e)     
            bool isMobileDevice;     
                wurflApi.deviceFileProcessor proc = new wurflApi.deviceFileProcessor(Server.MapPath("/wurfl.xml"));     
                wurflApi.capabilitiesGetter api = new wurflApi.capabilitiesGetter(ref proc);     
                isMobileDevice = bool.Parse(api.getCapability("is_wireless_device"));     
                isMobileDevice = Request.Browser.IsMobileDevice;     
            if (isMobileDevice)     
                Page.Theme = "Mobile";     
                Page.MasterPageFile = "/App_Master/Mobile.master";     

    now just change the base page for sitefinity pages to this new class (located at /sitefinity/cmsentrypoint.aspx) and you should be done!

    <%@ Page Inherits="DetectingPage" MasterPageFile="~/Sitefinity/Dummy.master" %> 

    for an example visit www.mcallen.net on a mobile device!

    hope this was helpful!

  4. Gregory
    Gregory avatar
    25 posts
    16 Mar 2009
    17 Mar 2009
    Link to this post
    Thank you very much I'll try this later today and report back when I have a chance.  I really appreciate the prompt reply.
  5. Gregory
    Gregory avatar
    25 posts
    16 Mar 2009
    18 Mar 2009
    Link to this post
    I think I may have missed a step, I created the codefile, changed the cmsentrypoint.aspx, placed both the codefile and the wurfl xml into the app_code folder. when I try to load the page it displays

    Compilation Error

    Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.

    Compiler Error Message: CS0246: The type or namespace name 'clsGlobalDeviceFileProcessor' could not be found (are you missing a using directive or an assembly reference?)

    Source Error:

    Line 21:         try
    Line 22:         {
    Line 23: clsGlobalDeviceFileProcessor proc = new wurflApi.deviceFileProcessor(Server.MapPath("/wurfl.xml"));Line 24:             wurflApi.capabilitiesGetter api = new wurflApi.capabilitiesGetter(ref proc);
    Line 25:             api.prepareNavigatorModelCapabilities(Request);

    Source File: c:\Program Files\telerik\Sitefinity3.5 Community\WebSites\PDATest2\App_Code\Mobiledetect.cs    Line: 23

    the wurfl site only provided an xml file, is there supposed to be a dll file?
  6. Gregory
    Gregory avatar
    25 posts
    16 Mar 2009
    18 Mar 2009
    Link to this post
    sorry that should say

    Line 23:             wurflApi.deviceFileProcessor proc = new wurflApi.deviceFileProcessor(Server.MapPath("/wurfl.xml"));
  7. Gregory
    Gregory avatar
    25 posts
    16 Mar 2009
    18 Mar 2009
    Link to this post
    Nevermind I found the library on the wurfl site the page loads now.
  8. Rahul Patel
    Rahul Patel avatar
    3 posts
    09 Dec 2005
    08 Jan 2010
    Link to this post
    I was trying to see the www.mcallen.net website on my iPhone but it looks the same as on the desktop.  Was the mobile version discontinued?

    Just wondering...
  9. SelAromDotNet
    SelAromDotNet avatar
    912 posts
    18 Jul 2012
    08 Jan 2010
    Link to this post
    mobile support on our main site is temporarily out due to some issues with our server, but most of our other sites are working using the techniques above, take a look at:


    hopefully before the end of this coming week we'll have the rest working on mobile again (got sick this week so it cut my plans short :(

    let me know if you have any questions!
Register for webinar
9 posts, 0 answered