Welcome Guest, Not a member yet? Register   Sign In
setting site to always use mobile views
#1

[eluser]bobbob[/eluser]
I am looking for an elegant solution that will always load the correct view.
For example I was considering something like this:

Code:
if($this->agent->is_mobile())
{
$this->session->set_userdata("agent") = "mob";
}else{
$this->session->set_userdata("agent") = "";
}

//Then I could load any view:

Code:
$this->load->view($this->session->userdata("agent").'anyview');

// then as long as I have a view for each
mobanyview.php
and
anyview.php


So has anyone got a better way of doing this?
Ideally I'd like to set this in the index.php file once or at least somewhere only once.
Any ideas how to handle this or a another way?

Oops wrong forum Smile
#2

[eluser]spurs_fan11[/eluser]
Have you considered the concept of responsive web design? Fantastic article here about this technique:

http://www.alistapart.com/articles/respo...eb-design/

I'm currently using the foundation CSS framework to achieve this. If you add in some CSS media queries then you can create desktop/tablet/mobile sites very easily without the need to query the user agent within codeigniter.

http://foundation.zurb.com/

* You'll have to copy/paste the links as this forum blocks me from using that feature. :/
#3

[eluser]bobbob[/eluser]
I think using foundation might be the answer.
I love alistapart. It is in my rss reader.
I read that article then but now it is more relevant to me. Just reread it.

Still interested if there is a way to hook into codeIgniter earlier in its process to set a more global $variable for the user agent.

Thanks spurs_fan11,

#4

[eluser]InsiteFX[/eluser]
Do asearch for 1140 fluid grid get that works with phones and mobile
#5

[eluser]ToddyBoy[/eluser]
What would you suggest if I wanted to display different data depending on user agent?
#6

[eluser]skunkbad[/eluser]
You could set the template in MY_Controller based on whatever logic you want to use.

$this->template = 'templates/mobile';

This is nice because you can use that to load the view in any controller method.

$this->load->view( $this->template );
#7

[eluser]ghprod[/eluser]
[quote author="InsiteFX" date="1328748322"]Do asearch for 1140 fluid grid get that works with phones and mobile
[/quote]

Thank insite, i've searched and found this http://cssgrid.net/
they had feature for auto resize image to fit with coloumn width .. nice one Smile




Theme © iAndrew 2016 - Forum software by © MyBB