Wednesday, January 03, 2007
Wordpress嵌入osCommerce/Wordpress和osCommerce 整合
Aug 22, 2006
帮朋友做了一个osCommerce的应用商城网站,在制作中需要把Wordpress和osCommerce整合。从国外网站找到了一片文章,按照他的说明整合完成,现在把步骤描述如下:
1、先在商城的目录中建立wordpress文件夹。安装wordpress,然后把wordpress的数据表迁移到osCommerce的数据库中,即整合数据库。这步不用多说,很简单,会使用phpMyAdmin就可以。
2、 在osCommerce商城根目录建立blog.php文件,内容如下:
- < ?php
- /*
- Title: Embedding WordPress into OS Commerce
- Author: Michael Wender (www.michaelwender.com)
- Disclaimer: This Software is provided "AS IS" and without warranty of any kind. The user assumes all risks associated with its use and installation.
-
- $Id: blog.php,v 1.1.1.1 2004/03/04 23:38:02 ccwjr Exp $
-
- osCommerce, Open Source E-Commerce Solutions
- http://www.oscommerce.com
- Copyright (c) 2003 osCommerce
-
- Released under the GNU General Public License
- */
- // turn off WordPress themes and include the WordPress core:
- define('WP_USE_THEMES', false);
- require('./wordpress/wp-blog-header.php');
-
- require('includes/application_top.php');
- require(DIR_WS_LANGUAGES . $language . '/' . FILENAME_BLOG);
- $breadcrumb->add(NAVBAR_TITLE, tep_href_link(FILENAME_BLOG));
- $content = CONTENT_BLOG;
- require(DIR_WS_TEMPLATES . TEMPLATE_NAME . '/' . TEMPLATENAME_BLOG_PAGE);
- require(DIR_WS_INCLUDES . 'application_bottom.php');
- ?>
3、打开oscommerce_root/includes/filenames.php 文件,找到“// define the content used in the project”注释,在下面加入:
- define('CONTENT_BLOG', 'blog');
在找到“// define the filenames used in the project”注释,在下面加入:
- define('FILENAME_BLOG', CONTENT_BLOG . '.php');
接着找到“// define the templatenames used in the project”注释,加入:
- define('TEMPLATENAME_BLOG_PAGE', 'blog_page.tpl.php');
4、建立blog模版文件:oscommerce_root/templates/your_template_dir/blog_page.tpl.php ,文件名blog_page.tpl.php。
在文件中拷贝下面代码。当然,这个文件是可以被修改定制的,您可以学会使用WordPress Loop模版语法,来调整显示的内容和样式等。
WordPress Loop说明地址:http://codex.wordpress.org/The_Loop
- echo HTML_PARAMS; ?>>
- charset= echo CHARSET; ?>">
- if ( file_exists(DIR_WS_INCLUDES . 'header_tags.php') ) {
- require(DIR_WS_INCLUDES . 'header_tags.php');
- } else {
- ?>
echo TITLE ?> - }
- ?>
echo (($request_type == 'SSL') ? HTTPS_SERVER : HTTP_SERVER) . DIR_WS_CATALOG; ?>"> - echo TEMPLATE_STYLE;?>">
- require(DIR_WS_INCLUDES . 'warnings.php'); ?>
-
- require(DIR_WS_TEMPLATES . TEMPLATE_NAME .'/header.php'); ?>
- // INSERT YOUR WordPress Loop Code HERE:
- if (have_posts()) :
- while (have_posts()) :
- the_post();
- the_content();
- endwhile;
- endif;
- // END WordPress Loop Code
- ?>
- require(DIR_WS_TEMPLATES . TEMPLATE_NAME .'/footer.php'); ?>
5、建立blog语言定义文件。目录:oscommerce_root/includes/languages/your_language/blog.php,文件名:blog.php
文件内容如下:
- /*
- Title: Embedding WordPress into OS Commerce
- Author: Michael Wender (www.michaelwender.com)
- Disclaimer: This Software is provided "AS IS" and without warranty of any kind. The user assumes all risks associated with its use and installation.
-
- $Id: blog.php,v 1.2 2004/03/05 00:36:42 ccwjr Exp $
-
- osCommerce, Open Source E-Commerce Solutions
- http://www.oscommerce.com
- Copyright (c) 2003 osCommerce
-
- Released under the GNU General Public License
- */
-
- define('NAVBAR_TITLE', STORE_NAME. ' Blog');
- define('HEADING_TITLE', 'Blog');
- ?>
6、完成整合,上面说明只是基本的整合方法,具体的内容美化还要花费一些经历。如果wordpress loop使用的好,整合效果会更理想。访问blog地址:http://your-domain.com/blog.php
英文网站: http://www.michaelwender.com/page/blog/archives/44/embedding-wordpress-into-os-commerce