CodeIgniter + Wordpress 集成 [英] CodeIgniter + Wordpress integration

查看:25
本文介绍了CodeIgniter + Wordpress 集成的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的网站是用 Wordpress 设计的.一些主题页面有一个定制的 PHP 脚本来预订东西,我想在 CodeIgniter 中对其进行重构,以获得更大的灵活性.问题:

My website is designed with Wordpress. Some theme pages have a custom made PHP script for booking things, which I want to refactor in CodeIgniter, to get more flexibility. Questions :

1) 如何在 WP 中使用 CI 功能与 CI 的路由系统?我是否必须制作一个 CI 页面 index.php/controller/page1/然后在 Wordpress 中调用它?

1) how to use CI functions in WP with CI's routing system ? Do I have to make a CI page index.php/controller/page1/ and then call it in Wordpress ?

2) 我是否必须使用 CodeIgniter视图"系统或 Wordpress主题页面"才能获得结果?

2) Do I have to use CodeIgniter "views" system or Wordpress "theme pages" to get my result ?

谢谢

推荐答案

我使用了以下内容.

我的目标是在某些页面上使用 CodeIgniter,而让 Wordpress 中的其他页面保持不变.我只有几个步骤:

My goal is to use CodeIgniter for some pages, and leave the other pages in Wordpress untouched. I only have a few steps to do it :

复制 WordPress 根目录下的 CI 文件夹

Copy CI folder at the Wordpress root

修改 CI 的 « index.php » 以添加一个包含将 WP 功能添加到 CodeIgniter :

Modify the « index.php » of CI to add an include which will add WP functions to CodeIgniter :

@require '../wp-load.php';
require_once BASEPATH.'core/CodeIgniter.php';

添加此行后,Wordpress 函数将可以在 CodeIgniter 中使用;它们将主要用于视图.

Once this line added, Wordpress functions will be usable in CodeIgniter ; they will be used mainly for views.

修改 WP 的 .htaccess 以不重写 CI 的 URL:在这一行之后:

Modify the .htaccess of WP to not rewrite CI's URLs : After this line :

 RewriteRule ^index.php$ - [L]

添加这一行:

RewriteCond %{REQUEST_URI} !^/(codeigniter_folder|codeigniter_folder/.*)$

然后 CI 视图可以使用 WP 功能.

Then CI views can use WP functions.

这篇关于CodeIgniter + Wordpress 集成的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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