I had the idea to handle this with an extra route to mobile actions in
config/routes.php:

$subdomain = substr(env("HTTP_HOST"), 0, strpos(env("HTTP_HOST"),
"."));

if (strlen($subdomain) > 0 && ($subdomain == "m" || $subdomain ==
"mobile")) {
  Router::connect(':controller/:action/*', array('prefix' => 'm'));
  Router::connect('/', array('controller' => 'pages', 'action' =>
'index', 'prefix' => 'm'));
}

Instead of, or additionally to the subdomain check, you can put the
mobile check in the condition. This way your urls will look the same
like before but internally the mobile actions (and views) with prefix
m are used.

In the mobile action, in case you need the same data as the desktop
action, you can simply call it this way before the mobile view is
rendered:

function m_view() {
  $this->view();
}

I don't know if this is best practice, but for me it's more clearly
arranged and you are more flexible if the mobile version differs alot
from the desktop version.

Regards,

Michael

David schrieb:
> Hey folks,
>
> I'm very new to Cake and couldn't find this satisfactorily addressed
> elsewhere:
>
> I'm developing an application for both mobile and desktop browsers. On
> the user end, I'd like this to be seamless, so no "/mobile" etc. Just
> curious as to be best practice for accomplishing this.
>
> First, I'm assuming I should use the the Request Handler's isMobile()
> function, and then use beforeRender()  to set the layout to the mobile
> version. But what about the actual view? Should I use switches inside
> each view? Is it, perhaps, better practice to use render() to change
> the view altogether to a separate mobile version?
>
> In addition, just how unreliable is the isMobile() function? Is it
> really worthwhile to setup a WURFL-based browser checker as a vendor?
>
> Thanks in advance for your help!
>
> -David
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to