CodeIgniter와 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()이 정의되었다는 문제점이있었습니다. 워드 프레스 파일은 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로 테스트되었습니다.
디렉토리 구조 :
/ - WordPress
/ci/ - codeigniter
/ci/index.php (CI 색인 파일의 맨) 기본 CodeIgniter의 버전을 재정 의하여 SITE_URL의 기능과 충돌
$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 프로젝트 템플릿을 그릴 get_header()
및/또는 get_footer()
기능 워드 프레스를 사용할 수 있습니다.
저는 커스텀 CI 전자 상거래 웹 사이트에서 기사를 관리하기 위해 Wordpress를 사용하고 있습니다. CI가 제 주요 사이트입니다.
CI의 의 index.php의 맨 위에 다음 코드를 추가 할 때 내가 엉망이되고 내 URL을하지 않고 내 CI 컨트롤러에 워드 프레스 기능을 사용할 수 있어요/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);
}
Jerome Jaglale (http://jeromejaglale.com/doc/php/codeigniter_i18n)의 CI i18n 라이브러리를 사용할 때도 작동합니다.
- 1. codeigniter와 wordpress 인증 통합
- 2. 기존의 WordPress 템플릿을 재정렬하는 방법?
- 3. Wordpress 템플릿을 HTMl + CSS
- 4. CodeIgniter와 ExpressionEngine
- 5. Wordpress - PHP 코드를 페이지에 통합하는 방법은 무엇입니까?
- 6. * * * WordPress 카테고리가 상위 카테고리 템플릿을 사용합니다.
- 7. 대괄호가있는 CodeIgniter와 params
- 8. Codeigniter와 Objective C 통합
- 9. codeigniter와 함께 __call을 사용하여 도움을
- 10. findbugs를 Maven에 통합하는 방법
- 11. cocos2d에서 UIImagepickerview를 통합하는 방법
- 12. 플래시와 MySQL을 통합하는 방법
- 13. 통합하는 방법 셰어 커뮤니티
- 14. Redis를 SQLAlchemy와 통합하는 방법
- 15. LINQ를 통합하는 방법
- 16. TFS를 SharePoint와 통합하는 방법
- 17. OpenId와 ASP.Net을 통합하는 방법
- 18. ASPNET에 Payseal을 통합하는 방법
- 19. matlab를 QT와 통합하는 방법
- 20. 페이스 북 통합하는 방법
- 21. 의욕을 IDEed와 통합하는 방법?
- 22. Bhoositukra를 .net과 통합하는 방법?
- 23. facebook api를 통합하는 방법
- 24. Xcode와 SVN을 통합하는 방법
- 25. prettyPhoto와 wicket을 통합하는 방법
- 26. BIRT와 Python을 통합하는 방법
- 27. openCV와 ARtoolkit을 통합하는 방법
- 28. YouTube에 iphone을 통합하는 방법
- 29. Cocos2d에서 AdBannerView를 통합하는 방법
- 30. ofbiz를 sharepoint에 통합하는 방법
완벽하게 감사합니다. –