O'Reilly logo

Yii Rapid Application Development Hotshot by James R. Hamilton III, Lauren J. O'Meara

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Detecting Mobile Browser – The Real Deal

In the previous tasks, we have quickly added mobile browser detection. In this task, we will refine that code.

Prepare for Lift Off

The file ch2| Source Files| js| url_param_proc.js contains functions for manipulating the parameter strings in the URL query string. We will include this file in our mobile layout and use it to manage the mobile parameter.

Open ch2 | Source Files | protected | views | layouts | main.php. After the following code snippet:

Yii::app()->clientScript->registerScriptFile(
Yii::app()->request->baseUrl . '/js/detectmobilebrowser.js'
);

Add the following lines of code:

Yii::app()->clientScript->registerScriptFile(
Yii::app()->request->baseUrl . '/js/url_param_proc.js'
);

Engage Thrusters

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required