Is there any way in the CI routing file I can find out if a view is using a mobile?
and if so rotate them to a different page?
I've got two sets of controllers one for mobile and one for desktop but I'd like the urls to always be the same.
I've tried adding the following code to the routes config file but I'm getting an error...
Am I thinking about this totally wrong?
$this->load->library('user_agent');
if ($this->agent->is_browser())
{
$route['default_controller'] = "index";
} elseif ($this->agent->is_mobile())
{
$route['default_controller'] = "m/index";
}
The error I'm getting is Undefined property: CI_Router::$load
From examining the CI system files, it appears that the Loader class is loaded after the Router class, so $this->load doesn't exist yet.
Check out CI Hooks, though: https://ellislab.com/codeigniter/user-guide/general/hooks.html
In addition, you might try using head.js (http://headjs.com/) and defining screen widths for Responsive Design. It enables you to build a web site and change the CSS to change the page depending on the width of the browser. Unless you are aiming at mobile/desktop due to functionality, screen size is the common reason we care what they are on, right? So, if it is screen size, I think the head.js system is the way to go. Then you have only one codebase of server-side stuff to worry about.