I want to build two versions of my project for mobile and desktop. Am working codeigniter 2.0.2, am looking for a way for the mobile and desktop versions of the project to share the same model, controllers, libraries, and helpers. Also i have set up a sub-domain,m.xyz.com to point to folde开发者_JAVA百科r called "m" on public_html folder, i want the the mobile to be in the "m" folder and share resources with the desktop app residing in root so i dont create duplicate models, controllers etc.
CodeIgniter allows you to specify the folder that you are loading your views from. Since you want to reuse all of your application code, simply set up CodeIgniter so that it is loading mobile optimized views rather than the default (desktop) views.
- Copy the root
index.php
file into the/m/
folder that you created. - Update the
$system_path
and$application_folder
variables in/m/index.php
with the correct paths. - Update the
$view_folder
variable in/m/index.php
with the path to your view folder containing your mobile optimized views.
You mobile site will now mirror your desktop site - it will just be pulling in different views.
Note that the structure of your mobile views folder will need to mirror the structure of your default views folder.
EDIT: The $view_folder
option will not be available until version 2.1. Here is the code if you wish to make the change yourself:
https://github.com/EllisLab/CodeIgniter/commit/8eef9c77512d4fad5357d3cbda83b89f844d7d16
精彩评论