Welcome Guest, Not a member yet? Register   Sign In
Template for mobile and computer - How?
#1

Hi

In my previous work, I used to detect the device and assigned the theme according to that.

Now, In CodeIgniter, How do i do that?
Something should run before the view is loaded.

How do i do that?
Reply
#2

(11-10-2014, 05:58 AM)agriz Wrote: Hi

In my previous work, I used to detect the device and assigned the theme according to that.

Now, In CodeIgniter, How do i do that?
Something should run before the view is loaded.

How do i do that?

For 2.x check here
Reply
#3

Thanks.

Can i run load user agent in pre_controller hooks? Is that good idea?
Reply
#4

I use it like in this example in My_controller ...
Reply
#5

I've recently started using the MobileDetect library for detecting whether it's a phone or tablet. Then, in however you do your views, you can then choose the mobile version or not. Though, to be 100% complete, you'll need to provide a way for the user to go to full site if they desire, even if on a mobile unit.
Reply
#6

You can use this lib: http://mobiledetect.net/

download this library and put it inside your library or third party folder and you should be able to use it like that:

Code:
public function index() {
    $this -> load -> library('Mobile_Detect');
    $detect = new Mobile_Detect();
    if ($detect->isMobile())
    {
        echo 'mobile';
    }
}

Reply
#7

Another approach is to use something like Foundation (http://foundation.zurb.com/) by Zurb or Bootstrap (http://getbootstrap.com/) by Twitter for your responsive template and then only rely on CI for the actual application part.

This might reduce your maintenance and provide a more efficient upgrade path.

Smile
Reply
#8

(This post was last modified: 11-14-2014, 09:42 PM by includebeer.)

+1 for Bootstrap!
No need to detect if it's a phone, a tablet or whatever else. It adjust the layout according to the screen resolution and it's all in CSS!
Reply
#9

My 2 Cents on Bootstrap...(Responsive design)

1. Our page load time is always high because all content gets loaded (For desktop,tablet, phone) once and then got fit into client's browser as per width and height.

If we go with the user agent identification approach and delivering appropriate view, it will reduce page load time because on mobile phone, we have very less bandwidth.
Reply
#10

for the most part responsive design can be handled client side via CSS and javascript. But as tapan.thapa mentioned bandwidth can be an issue because most cell providers limit monthly bandwidth with a cap.

So if you have a site that has large sized Kb like images, ect ... utilizing some type of user agent ident would be a good idea.

when you have the user agent variable you can simply toggle the loaded view between IE: home.php (PC) or home_mobile.php (Tablets, Smartphones, ect ...) this way you can tailor the content to devices with lower bandwidth caps.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB