CodeIgniterとWordPressを統合して、 のLook&Feel/TemplateのWordPressブログをCodeIgniterが作成したページに引き継ぐ方法を教えてください。WordPressのテンプレートをCodeIgniterと統合する方法
答えて
最初のステップは、CodeIgniterとWordPressファイルをそれぞれのディレクトリに移動することです。
その後、CodeIgniterのindex.php
ファイルの先頭に次の行を挿入します。必要に応じてパスをwp-blog-header.php
に変更して、WordPressのルートディレクトリを指定します。
<?php
require('../wp-blog-header.php');
その後、あなたはあなたのビュー内の以下の機能を使用することができます。
<?php
get_header();
get_sidebar();
get_footer();
?>
他のヘルパー関数も デザインを統合する際に役立ちますワードプレスのドキュメントで見つけることができます。
Codeigniterのindex.phpページにwp-blog-header.phpファイルを含めると、codeigniterのURLヘルパーとWordPressの両方でsite_url()が定義されているという問題が発生しました。 WordPressのファイルをHTTPレスポンスヘッダ「HTTP/1.0が見つからない404ページ」ヘッダにを追加したよう
require('blog/wp-blog-header.php');
add_filter('site_url', 'ci_site_url', 1);
function ci_site_url() {
include(BASEPATH.'application/config/config.php');
return $config['base_url'];
}
header("HTTP/1.0 200 OK");
最終行を追加する必要があります:私は、次のコードを使用して、これを解決しました。
これで、WordPress関数を使用してCodeIgntierを呼び出すことができます。あなたのコード内のコードの点火SITE_URL機能を使用して計画している、または既存のCIのサイトとWPのマージをやっている場合ならば
...これが役に立つかもしれません:上部の
CIのindex.phpをの:
require_once '../wp-blog-header.php';
add_filter('site_url', 'ci_site_url', 4);
function ci_site_url($url, $path, $orig_scheme, $blog_id) {
$CI =& get_instance();
$new_path = str_replace("YOURSITEURLGOESHERE", "", $url);
return $CI->config->site_url($new_path);
}
効果的にこれは、すでにあなたのプロジェクトへのリンクやコンテンツのトンを追加した場合、それはあなたを助けるかもしれないので、あなたは、CIにSITE_URLを使用することができます。
codeigniterプロジェクトでWordPressテンプレートを使用する別の方法があります。これは私にとってはうまくいくので、私はそれを共有したいと思っていました。 WordPress 3.3.1とCodeigniter 2.1でテスト済み
ディレクトリ構造:デフォルトのCodeIgniterのバージョンをオーバーライドすることによりSITE_URL機能衝突と
/ - WordPress
/ci/ - codeigniter
/ci/index.php(CIインデックスファイルの先頭)
$wp_did_header = true;
if (defined('E_RECOVERABLE_ERROR'))
error_reporting(E_CORE_ERROR | E_CORE_WARNING | E_COMPILE_ERROR | E_ERROR | E_WARNING | E_PARSE | E_USER_ERROR | E_USER_WARNING | E_RECOVERABLE_ERROR);
else
error_reporting(E_CORE_ERROR | E_CORE_WARNING | E_COMPILE_ERROR | E_ERROR | E_WARNING | E_PARSE | E_USER_ERROR | E_USER_WARNING);
require_once("../wp-config.php");
ディール。コード番号でsite_url()
を使用した場所を変更して、代わりにci_site_url()
を使用する必要があります。
/ci/application/helpers/MY_url_helper.php
<?php
function anchor($uri = '', $title = '', $attributes = '')
{
$title = (string) $title;
if (! is_array($uri))
{
$site_url = (! preg_match('!^\w+://! i', $uri)) ? ci_site_url($uri) : $uri;
}
else
{
$site_url = ci_site_url($uri);
}
if ($title == '')
{
$title = $site_url;
}
if ($attributes != '')
{
$attributes = _parse_attributes($attributes);
}
return '<a href="'.$site_url.'"'.$attributes.'>'.$title.'</a>';
}
if (! function_exists('ci_site_url'))
{
function ci_site_url($uri = '')
{
$CI =& get_instance();
return $CI->config->site_url($uri);
}
}
function current_url()
{
$CI =& get_instance();
return $CI->config->ci_site_url($CI->uri->uri_string());
}
function anchor_popup($uri = '', $title = '', $attributes = FALSE)
{
$title = (string) $title;
$site_url = (! preg_match('!^\w+://! i', $uri)) ? ci_site_url($uri) : $uri;
if ($title == '')
{
$title = $site_url;
}
if ($attributes === FALSE)
{
return "<a href='javascript:void(0);' onclick=\"window.open('".$site_url."', '_blank');\">".$title."</a>";
}
if (! is_array($attributes))
{
$attributes = array();
}
foreach (array('width' => '800', 'height' => '600', 'scrollbars' => 'yes', 'status' => 'yes', 'resizable' => 'yes', 'screenx' => '0', 'screeny' => '0',) as $key => $val)
{
$atts[$key] = (! isset($attributes[$key])) ? $val : $attributes[$key];
unset($attributes[$key]);
}
if ($attributes != '')
{
$attributes = _parse_attributes($attributes);
}
return "<a href='javascript:void(0);' onclick=\"window.open('".$site_url."', '_blank', '"._parse_attributes($atts, TRUE)."');\"$attributes>".$title."</a>";
}
function redirect($uri = '', $method = 'location', $http_response_code = 302)
{
if (! preg_match('#^https?://#i', $uri))
{
$uri = ci_site_url($uri);
}
switch($method)
{
case 'refresh' : header("Refresh:0;url=".$uri);
break;
default : header("Location: ".$uri, TRUE, $http_response_code);
break;
}
exit;
}
今、あなたのCIプロジェクトにテンプレートを描画するためのWordPress get_header()
および/またはget_footer()
機能を使用することができます。
私はWordpressを使用してカスタムCI電子商取引ウェブサイトの記事を管理しています。 CIが私のメインサイトです。私はindex.phpの CIのの先頭に次のコードを追加するとき、私のURLが台無しにされることなく、私のCIコントローラにWordpressの機能を使用することができるよ
/application (CI)
/... (directories like javascript, stylesheets ...)
/system (CI)
/wordpress
/.htaccess
/index.php (CI)
:ディレクトリ構造は以下のとおりです。
require_once './wordpress/wp-blog-header.php';
add_filter('site_url', 'ci_site_url', 1);
function ci_site_url($uri = '') {
$CI =& get_instance();
$uri = ltrim(str_replace($CI->config->base_url('wordpress/'), '', $uri),'/'); // "wordpress/" is in my case the name of the directory where I installed Wordpress. See directory structure above.
return $CI->config->site_url($uri);
}
JérômeJaglale(http://jeromejaglale.com/doc/php/codeigniter_i18n)がCI i18nライブラリを使用している場合にも機能します。
- 1. CodeIgniter + Wordpress統合
- 2. CodeIgniterとWordpressの統合
- 3. Wordpress統合によるCodeigniter
- 4. Wordpress:メディアアップローダとカスタムメタボックスフィールドを統合する方法は?
- 5. CodeIgniterとphpBB3ユーザシステムの統合
- 6. DoctrineとCodeIgniterの統合
- 7. codeigniterとzendを統合するエラー
- 8. Wordpress PostとCakephp3を統合
- 9. Wordpressプラグインとの統合Uploadify
- 10. wordpressとApacheを統合する
- 11. WordpressとCakephpを統合するには?
- 12. PHPで異なるモジュールを統合する方法Codeigniter
- 13. WordPressテーマのオプションツリーを統合する方法
- 14. codeigniterテンプレート、サイドバーを追加する方法
- 15. Invision Power BoardとCodeigniterを統合
- 16. サードパーティのdjangoアプリケーションとテンプレートを統合
- 17. CodeIgniterにSkrillを統合するには?
- 18. WordpressでのFacebookの統合
- 19. RedisとSQLAlchemyを統合する方法
- 20. カルマをTeamCityと統合する方法
- 21. ofbizとsharepointを統合する方法
- 22. NHibernateとLucene.Netを統合する方法
- 23. PhpBBをmoodleと統合する方法
- 24. AjaxをSymfony2と統合する方法
- 25. Google +とアプリを統合する方法
- 26. JayDataとKnockoutを統合する方法
- 27. jprofileとnetbeansを統合する方法
- 28. Wordpressモバイル統合ですか?
- 29. FacebookとWordpressまたはDrupalの統合
- 30. Ruby on RailsとWordpressの統合サイト
完璧に感謝マン –