Joomla!, Wordpress tips for building your site

How to convert from posts of Joomla! to Wordpress

Published on| April 1st, 2010 | 1 Comment.

If you want to convert from posts of Joomla! to WordPress , this post maybe help you.
I will explain how to convert by using php script of following site.

See : “Joomla to WordPress, Content Converter

Let’s edit ‘wp-config.php’

First step, you should be downloading php script files from above-mentioned site.

Next step, you should melt from the zip file to any directory.

So next, you will edit ‘config.php’ file like a following code.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
<?php
/* 
 * Configuration for your Database and stuff
 */
 
$SQL['HOST'] = "sql.lan";   // Normaly localhost
$SQL['USR'] = "user";
$SQL['PWD'] = "pass";
 
// Joomla realted ->
$SQL['JOOMLA_DB'] = "solariz_de"; // Databse name of Joomla
$SQL['JOOMLA_PRE'] = "jos_";    // Table Prefix of Joomla Tables
 
// WordPress realted ->
$SQL['WP_DB'] = "solariz_wp"; // Databse name of wordpress
$SQL['WP_PRE'] = "wp_";       // Table Prefix of wordpress Tables
 
$DEFAULTS['POST_AUTHOR']   = 1; // User ID of target Author (1 usualy admin)
$DEFAULTS['POST_CATEGORY'] = 5; // I suggest to create a category named e.g. import
 
// If you are done with your configuration comment the next line out
// or set it to false.
$NOT_CONFIGURED = true;
 
//EOF: No PHP Endtag to avoid messup of headers

5 line : edit server name or IP address of database.
6 line : edit user name of database.
7 line : edit password of database.

11 line : edit database name that is used by Joomla!.
12 line : edit prefix name that is used by Joomla!.
So, you will know prefix name by seeing “configuration.php” file in directory that Joomla! was installed.
Following examle, you will edit “jos_” at 12 line.

	var $dbprefix = 'jos_';					// Do not change unless you need to!

14 line : edit database name that is used by WordPress.
15 line : edit prefix name that is used by WordPress.
So, you will know prefix name by seeing “wp-config.php” file in directory that WordPress was installed.
Following examle, you will edit “wp_” at 14 line.

$table_prefix  = 'wp_';

Last edit.
27 line : $NOT_CONFIGURED = false;

You should save the php file.

Let’s edit ‘functions.inc.php’

You will notice that some functions was edited in ‘functions.inc.php’.
And, you might notice some problems.
You should re-edit for some problems.

[before changing]

57
58
59
60
61
62
63
    foreach ($array as $k => $v) {
        if($k AND $v) {
            if($inserted > 0) $query .= ",";
            $query .= "`".$k."` = '".mysql_escape_string(str_replace("`","",$v))."'";
            ++$inserted;
        }
    }

[after changing]

57
58
59
60
61
62
63
64
65
66
67
68
69
    $inserted = 0;
    foreach ($array as $k => $v) {
        //if($k AND $v) {
        if($k ) {
            if($inserted > 0) $query .= ',';
            if($v){
                $query .= '`'.$k."` = '".mysql_escape_string(str_replace("`","",$v))."'";
            } else {
                $query .= '`'.$k."` = ''";
            }
            ++$inserted;
        }
    }

57 line : $inserted initialized.
You will notice that $inserted is seen in loop before initialized.

Let’s edit ‘index.php’

You will notice that program for convert was edited in ‘index.php’.
And, you might notice some problems.
You should re-edit for some problems.

37
38
if(function_exists(set_time_limit)) set_time_limit(1800);
else                                $OUT .= "<li>Warning: cant't execute set_time_limit() script may abort...";

This line means that set php script process time.
Example, rental server might not be able to set it.
I will explain taht execute php script at console. And you will do comment-out its lines.

And you should edit like the following codes for table of WordPress.
[before changing]

58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
    $array = array(
        "post_author"=>$DEFAULTS['POST_AUTHOR'],
        #"post_parent"=>$DEFAULTS['POST_CATEGORY'],
        "post_date"=>$R['created'],
        "post_date_gmt"=>$R['created'],
        "post_modified"=>$R['modified'],
        "post_modified_gmt"=>$R['modified'],
        "post_title"=>$R['title'],
        "post_status"=>"publish",
        "comment_status"=>"open",
        "ping_status"=>"open",
        "post_name"=>$R['alias'],
        "post_type"=>"post"
    );
    if($R['fulltext'])  $array["post_content"] = $R['fulltext'];
    elseif($R['introtext'] AND !$R['fulltext']) $array["post_content"] = $R['introtext'];
 
	// Content Filter
	$array["post_content"] = str_replace('<hr id="system-readmore" />',"<!--more-->",$array["post_content"]);
	$array["post_content"] = str_replace('src="images/','src="/images/',$array["post_content"]);
 
    $sql_query[] = wpBuildQuery($SQL['WP_PRE']."posts", $array);

[after changing]

58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
    $array = array(
        "post_author"=>$DEFAULTS['POST_AUTHOR'],
        #"post_parent"=>$DEFAULTS['POST_CATEGORY'],
        "post_date"=>$R['created'],
        "post_date_gmt"=>$R['created'],
        "post_modified"=>$R['modified'],
        "post_modified_gmt"=>$R['modified'],
        "post_title"=>$R['title'],
        "post_status"=>"publish",
        "comment_status"=>"open",
        "ping_status"=>"open",
        "to_ping"=>"",
        "pinged"=>"",
        "post_content_filtered"=>"",
        "post_name"=>$R['alias'],
        "post_type"=>"post"
    );
 
    if($R['fulltext'])  $array["post_content"] = $R['fulltext'];
    elseif($R['introtext'] AND !$R['fulltext']) $array["post_content"] = $R['introtext'];
 
	// Content Filter
	$array["post_content"] = str_replace('<hr id="system-readmore" />',"<!--more-->",$array["post_content"]);
	$array["post_content"] = str_replace('src="images/','src="/images/',$array["post_content"]);
 
	//	if your system do not support MB String, you should use functons(ex. strpos, substr ,etc,.) for normal strings.
	$pos = mb_strpos($array['post_content'], '<!--more-->',0,'UTF-8');
	if($pos===false){
		if(mb_strlen ($array['post_content'],'UTF-8')>128){
			$array['post_excerpt'] = mb_substr($array['post_content'],0,128,'UTF-8');
		} else {
			$array['post_excerpt'] = $array['post_content'];
		}
	} else {
		$array['post_excerpt'] = mb_substr($array['post_content'],0,$pos,'UTF-8');
	}
 
    $sql_query[] = wpBuildQuery($SQL['WP_PRE']."posts", $array);

80 line : ‘post_excerpt’ means excerption of the post. So this program will edit this information within 128 characters or less.

Let’s convert!

Let’s convert from Joomla! to WordPress

This script will execute by web access.
But it will execute by console at this time.

First step, you should change current directory to directory of php script files.
Next , you will input command like the following.

> php index.php > error.log

If this script will be occurred any errors, error information will be written to ‘error.log’.
If you will not notice any errors, error information will be written to ‘error.log’ like the following.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
		<title>Joomla 2 WordPress by www.solariz.de</title>
	</head>
<body>
<li> Processing 125 Posts...<br><li>Inserted 125 ID's
</body>
</html>

Note : same nuber.
<li> Processing 125 Posts…<br><li>Inserted 125 ID’s

After you completed convert of DB, let’s see WordPress site.


This picture is WordPress site that convert ‘www.off-soft.net’ site(Joomla!).

Note

In this way, only the article is only converted.
You should note that menu, categories ,sections, and database of plug-in was not convert.

But you will be able to edit php script if you understand this post and WordPress , Joomla!.

joomla2wordpress php script - joomla2wordpress php script





Comments

One Response to “How to convert from posts of Joomla! to WordPress”

  1. Tweets that mention How to convert from posts of Joomla! to Wordpress | Joomla!, Wordpress tips for building your site — Topsy.com
    April 2nd, 2010 @ 21:00:10

    […] This post was mentioned on Twitter by Dan James, Kind Canine. Kind Canine said: How to convert from posts of Joomla! to WordPress | Joomla …: Joomla!, WordPress tips for building your site. Jo… http://bit.ly/aVorZX […]

Leave a Reply








Transrator

Recent Posts

Categories

Tag Cloud

execute remove フロントページ 投稿ページ トップページ install WIndows Note Convert META generator 日付 donwload file manage multibyte utf-8 unicode shiftjis euc console サイトマップ 問題 ParmaLink Redirect パーマリンク はみ出る pre テンプレート テーマ タグクラウド マルチランゲージ リダイレクト PHP(タグ) タグ table control HTML(タグ) コマンド 国際化(翻訳) SQLite(タグ) MySQL(タグ) qTranslate プラグイン(タグ) Wordpress(タグ)

Links

Site Description

Joomla!, Wordpress as CMS using a site building, site management, software usage to describe the development tips.

  • はてなブックマークへ追加する
  • Facebookでシェアする
  • twitter でつぶやく
  • Google Plusでシェアする
  • Pocketでシェアする
ページトップへ