移动和桌面web应用程序与codeigniter [英] Mobile and desktop web app with codeigniter

查看:83
本文介绍了移动和桌面web应用程序与codeigniter的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想为移动设备和桌面版创建两个版本的项目。
我正在工作的codeigniter 2.0.2,我正在寻找一种方式为项目的移动和桌面版本共享相同的模型,控制器,库和助手。
我还设置了一个子域m.xyz.com指向public_html文件夹下的m文件夹,
i希望移动设备在m文件夹中并共享资源与桌面应用程序驻留在根目录,所以我不要创建重复的模型,控制器等。

解决方案

CodeIgniter允许您指定文件夹您正在载入您的视图。由于您想重复使用所有应用程序代码,因此只需设置CodeIgniter,即可加载移动优化视图,而不是默认(桌面)视图。


  1. 将根 index.php 文件复制到您创建的 / m / 文件夹中。

  2. 更新中的 $ system_path $ application_folder $ / code>

  3. 更新 $ view_folder



p>您的移动网站现在将镜像您的桌面网站 - 它只会拉不同的视图。



请注意,您的移动视图文件夹的结构将需要镜像



编辑 $ view_folder 直到版本2.1。如果您希望自己进行更改,请参阅以下代码:



https://github.com/EllisLab/CodeIgniter/commit/8eef9c77512d4fad5357d3cbda83b89f844d7d16


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 folder 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.

  1. Copy the root index.php file into the /m/ folder that you created.
  2. Update the $system_path and $application_folder variables in /m/index.php with the correct paths.
  3. 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

这篇关于移动和桌面web应用程序与codeigniter的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆