Welcome Guest, Not a member yet? Register   Sign In
Multiple version of same app (Mobile)
#1

[eluser]bapobap[/eluser]
Hey all,

I was wondering if anyone had any tips on how best to handle this? I have an app that needs to be available as a normal browser version, iPhone version, XHTML for mobile and finally WML.

All will use the same database but depending on how your accessing the app, you'll get varying levels of comprehensiveness and in some cases will get a slightly different interface.

I started off by detecting what version to provide, then sending the right header and footer accordingly. However, I'm not sure how to handle controllers and views. I'm also using a Universal controller that handles everything which might make things harder.

Should I be using 4 separate copies of CI or is there a smarter way to do this?

Thanks
#2

[eluser]xwero[/eluser]
I think the best way to handle this is to detect the useragent and the screen size with the default controller and based on that data you can set the css and the output. The most logical file structure for the view files would be different directories for each output version.
Code:
// default controller
$this->session->set_userdata('output',$useragent);
redirect('welcome');
// some page
function page()
{
   $this->load->view($this->session->userdata('output').'/view');
}
I think it can be done with a minimum of code overhead if you do it right.
#3

[eluser]bapobap[/eluser]
Thanks for your reply.

That's fairly close to the method I was using (I didn't think to use sessions to store it though).

It is possible to use a different controller in my main controller?

So:

if browser // continue as normal
if iphone // use the special iphone controller
if mobile // use the light xhtml controller

etc

In the old app, if it detected an iPhone, you would get sent to /iphone/ and a whole separate set of code was coded to greet you. With this, I'd prefer it if CI did all the magic but I would like to use separate controllers (but not separate URLs), just to make my life easier.

Is this possible or even a good idea?

Thank again!
#4

[eluser]bapobap[/eluser]
I think I'll just go with different versions on different URL's, I can then setup the exceptions to my catch-all controller in routes and just have different controllers for those parts. I think my main problem is I haven't thought anything through!

One quick question if anyone knows, a lot of my app is based around the URI being requested, is there a better way of doing this:

if ((isset($this->uri->router->segments[4])) && ($this->uri->router->segments[4]=='filter')):

If I don't check if it's set, I get an undefined offset notice, which is fair enough but maybe there is a better way to test this.

Thanks!




Theme © iAndrew 2016 - Forum software by © MyBB