Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
386 views
in Technique[技术] by (71.8m points)

CodeIgniter + Wordpress integration

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) 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) Do I have to use CodeIgniter "views" system or Wordpress "theme pages" to get my result ?

Thanks

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

I used the following.

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 :

Copy CI folder at the Wordpress root

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';

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

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

 RewriteRule ^index.php$ - [L]

Add this line :

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

Then CI views can use WP functions.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...