I'm still trying to figure out a way to get a mobile site running. I have a web app in CodeIgniter and I would like to create a mobile version of it. However, I don't want to rewrite too much of my code, especially not my models.. (Since they return raw data which I can use anywhere.)
I want to run my mobile website at a subdomain (m.mydomain.tld
). The desktop version runs at www.mydomain.tld
. I tried pointing the subdomain to my CI application folder; when a mobile browser arrives at www.mydomain.tld
, I redirect it to m.mydomain.tld
. This subdomain is, as I said, pointed at my CI applicaiton folder; I then serve mobile-optimised controllers and views.
However! As specified in app/config/config.php
, the base_url of my application is:
$config['base_url'] = 'http://www.mydomain.tld/';
So redirecting to m.mydomain.tld
doesn't really work because I still get redirected to www
and I don't want that, even though it then does what I want it to do.
The way I'm trying to solve this is making two application folders with different controllers/views, but shared models etc. So, I'm trying to figure out a way to restructure my CodeIgniter application so I can share my models and 'custom controller' (MY_Controller), as well as some custom libraries/helpers between different applications.
I hope this is clear, if not I'll gladly explain more what I'm looking for. Thanks a lot!
Maybe you should take a look at codeIgniter's 2.0 new feature : package.
Packages allow you to share librairies, models etc. with :
$this->load->add_package_path('/usr/local/codeigniter/shared');
Read this: http://philsturgeon.co.uk/blog/2010/04/codeigniter-packages-modules
Hope it helps.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With