Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • CakePHP website mobile version

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 651
    Comment on it

    Hello All,


    In this blog we will discuss about how to make your website working with proper layout in the mobile devices.

    For this we can use CakePHP's RequestHandler's isMobile function to check if a mobile device is accessing the site.

    We can make this liable by putting following code in the AppController by using cakephp beforeRender function.

    public $components = array('RequestHandler');
    public function beforeRender() {
        parent::beforeRender();
        if ($this->RequestHandler->isMobile()) {
            $this->layout = 'mobile';
        }else{
        $this->layout = 'WebsiteLayout';
        }
    


    The above code will check if the request has come in from mobile device or not.

    Lastly, by setting this criteria It sets a property and view variable to allow actions and views to adjust based on the mobile layout we define by checking if the mobile device is accessing it.

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: