Maybe you can just use strict XHTML and CSS as the default layout.
This ensures the web will be viewed perfectly in both browsers. In
https://addons.mozilla.org/es-ES/firefox/addon/249 you can see an html
and xhtml validator addon for mozilla firefox based on the w3c method.

Anyway, the simplest form of auto layout selection is modifying the
Controller constructor (cake 1.1, don't know the difference with cake
1.2)

/cake/libs/controller/controller.php

In function __construct() just put:

                if(CONDITIONS FOR MOBILE BROWSER)
                        $this->layout = 'the-layout-for-mobile';
                else
                        $this->layout = 'default-layout for pc browser';

In CONDITIONS you can use php global variables, example

                if($_SERVER['REMOTE_ADDR'] == '127.0.0.1')
                        $this->layout = 'default';
                else
                        $this->layout = 'layout2';

I thinls _SERVER['HTTP_USER_AGENT'] can show you the kind of client.
Don't know if you can just use PHP's get_browser() function

Greetings and sorry for my poor english!

On 8 jun, 15:53, Flan <[EMAIL PROTECTED]> wrote:
> I'm looking at putting together a WEB site that can be viewed as
> easily with a mobile/cell phone browser as a normal PC type browser.
> At the moment it seems I have 2 options:
>
> 1) switch the layout depending on whether the client is mobile or not
> (i.e. $this->layout = some_layout)
>
> 2) Use the WEBService switch.
>
> Problem with 1) is I want to change  the content of the mobile WEB
> page as well as the layout and I don't want to have lots of switches
> in the controller and view classes.
>
> Problem with 2) is that a different URL is required to access the WEB
> page (e.g. xml/controller/action) and I would really like to keep the
> same URL for both cases.
>
> In CakePHP is it possible to use a single URL, detect the browser
> type, store the type for example in the session, and then redirect the
> controller and action, depending on the type, as in the WEBServices
> options?
>
> I hope I have made a little bit of sense here but any help or ideas
> would be much appreciated.


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to [email protected]
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