stephenjbell

Mobile detection - dotCMS

Apr 29th, 2011
245
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.16 KB | None | 0 0
  1. ################## Save "siteversion" Query String Value to Session Variable
  2. #if($UtilMethods.isSet($request.getParameter("siteversion")))
  3. $session.setAttribute("siteversion",$request.getParameter("siteversion"))
  4. #end
  5.  
  6.  
  7.  
  8. ################## Ugly, overly complicated logic to make sure the page displays how it should (mobile or full)
  9.  
  10. #set($mobile="false") ## Default to desktop version
  11. ##Setting mobile = false to begin with.
  12.  
  13. #if($session.getAttribute("browserSniffer").mobile)
  14. #set($mobile="true")
  15. ##Setting mobile = true based on sniffer.
  16. #end
  17.  
  18. #if($session.getAttribute("siteversion") == "full")
  19. #set($mobile="false")
  20. ##Setting mobile = false based on session var.
  21. #end
  22.  
  23. #if($session.getAttribute("siteversion") == "mobile")
  24. #set($mobile="true")
  25. ##Setting mobile = true based on session var.
  26. #end
  27.  
  28. ## Query string values trump session variables if they conflict
  29.  
  30. #if($request.getParameter("siteversion") == "full")
  31. #set($mobile="false")
  32. ##Setting mobile = false based on query string.
  33. #end
  34.  
  35. #if($request.getParameter("siteversion") == "mobile")
  36. #set($mobile="true")
  37. ##Setting mobile = true based on query string.
  38. #end​
Advertisement
Add Comment
Please, Sign In to add comment