MrFoh
MrFoh

Reputation: 2701

Mobile site with codeigniter sharing resources

I have a desktop version of a site built with codeigniter ,and am creating the mobile version. I create a sub domain, m.xyz.com whose document root is public_html/m I have also place an index.php file in the /m folder and edited the $system_folder and $application_folder to point the application and system folder of the desktop site in order to share controllers and models. But when i try out the mobile domain, it still renders the desktop site. What do i need to do to fix this

Upvotes: 0

Views: 817

Answers (1)

Joris Ooms
Joris Ooms

Reputation: 12038

Use the User Agent Class: http://codeigniter.com/user_guide/libraries/user_agent.html

Use this in your controller to determine whether or not the user is on a mobile device:

if($this->agent->is_mobile())
{
 // handle mobile devices
}

And then render your mobile views inside the if.

Upvotes: 2

Related Questions