1 person found this helpful
The most common two ways of doing this are:
- Use a separate site or subdirectory like you described -- one for mobile, one for desktop (or "full" site).
- Use a MVC framework like FuseBox or Mach II and have separate views for the different formats.
I lean toward the second option but if your site does not already use a MVC framework, this is a huge undertaking and most likely not an option.
As to you second question, I would store it in a cookie and allow the user to toggle between the two.
Thanks for the info. I will go with the subdirectory route. Now my issues have to do with the fact that I will now have 2 login pages, one for desktop and one for mobile. My authentication begins in OnRequestStart, and includes the login page(rather than using cflocation) if the user is not authenticated or the user/password combo is invalid. The issue with this is the fact that the images on the login pages will not display correctly because if a mobile user is trying to hit the desktop version of the site, it will include the mobile login page with an incorrect path to the images. The mobile/login.cfm has path to images "../images/pic.png" and the login.cfm has this path: "images/pic.png". There are several instances of this occurring and it has to do with using a sub directory. I am trying to find a way around this issue the correct way with minimal code. I could have one login page(with both versions of the login page) where it detects the browser rather than having the detection in the application.cfc method. Any thoughts?
I already have 2 login pages as you suggest. The specific issue I have now is the fact that when a user tries to log into the desktop site with a mobile device and is NOT logged in, it goes through the logic to see if they are logged in and if not, the mobile login page gets included(because I am detecting the user on a mobile device). The problem is the fact that the logo is not displayed correctly because the mobile/login.cfm page is being included from the webroot/application directory rather than webroot/application/mobile directory. The mobile/login.cfm has path to images "../images/pic.png" and if it had this path: "images/pic.png" it would work fine. I cannot change the path, however, because if the user times out in the mobile directory, for example, "images/pic.png" would not work, but "../images/pic.png" would. I am not big on putting conditional logice everywhere to fix this. I am sure I am missing something very easy. Thanks for your help.
I solved this issue by adding another application.cfc in the mobile directory:
<cfset this.name="mobile" >
<cffunction name = "onApplicationStart">
Then, I just check if the user is on the mobile site or not with:
<cfif application.applicationname EQ 'mobile'>
do something else
Thanks for the help