Difference between revisions of "6CC001 Workshop - Mobile"
From mi-linux
Jump to navigationJump to search (Created page with "Main Page >> Advanced Web Technologies >> Workbook >> Week 08") |
|||
Line 1: | Line 1: | ||
[[Main Page]] >> [[6CC001|Advanced Web Technologies]] >> [[6CC001 - Workbook|Workbook]] >> Week 08 | [[Main Page]] >> [[6CC001|Advanced Web Technologies]] >> [[6CC001 - Workbook|Workbook]] >> Week 08 | ||
+ | |||
+ | The easiest way to create a mobile version of a website when using a Web Framework is to use the helpers provided. | ||
+ | |||
+ | For example CodeIgniter features a is_mobile() helper that you can use to load different views in your controllers (desktop or mobile): | ||
+ | |||
+ | <pre> | ||
+ | if ($this->agent->is_mobile('iphone')) | ||
+ | { | ||
+ | $this->load->view('iphone/home'); | ||
+ | } | ||
+ | else if ($this->agent->is_mobile()) | ||
+ | { | ||
+ | $this->load->view('mobile/home'); | ||
+ | } | ||
+ | else | ||
+ | { | ||
+ | $this->load->view('web/home'); | ||
+ | } | ||
+ | </pre> |
Revision as of 15:51, 12 March 2014
Main Page >> Advanced Web Technologies >> Workbook >> Week 08
The easiest way to create a mobile version of a website when using a Web Framework is to use the helpers provided.
For example CodeIgniter features a is_mobile() helper that you can use to load different views in your controllers (desktop or mobile):
if ($this->agent->is_mobile('iphone')) { $this->load->view('iphone/home'); } else if ($this->agent->is_mobile()) { $this->load->view('mobile/home'); } else { $this->load->view('web/home'); }