24 Mar, 2009  |  Written by User ImageDan (Who am I?)  |  under Uncategorized

I have updated the converter to remove the debug code.

I tested this with Wordpress 2.7.1 and Joomla 1.0.x.

Please ensure you configure each of the database sections correctly. I have receieved a lot of support requests where people are getting “Table does not exist” errors, these in each case have turned out to be a result of a miss configuration in the converter config file.

Rate this:
2.1

I have made a change to the Wordpress to Joomla converter that allows you tochoose not to import comments. This is a small change to the config.php and content.php file. I also need to remove the debugging from the content.php page which has been rolled into this version.

The download link on the downloads page links to the new wp2joomla.zip file

Rate this:
2.1
13 Jan, 2009  |  Written by User ImageDan (Who am I?)  |  under Uncategorized

I have always been a great lover of music and to an extent I can appreciate good ar, my talents in these areas however are lacking. I have always thought it to be one of the great injustices of this world, that someone who loves and appreciates music so much, lacks the talent to create music of their own.

This topic in general struck a chord with me whilst I was watching television one day, whilst nursing my self through a flu, there was an interview with an actor and they mentioned the phrase “this is your art” and other phrases along the same lines “suffer for you art” etc. This got me to thinking. What is my art? and why is their art considered an art over the things that I can do, and at the end of the day I concluded 2 things

  1. Art is simply a skill
  2. I do have an art, and that art is coding…PHP coding

I think the skills of so many coders out there are so heavily underated, some of the creations of so many digital artists. Things like Facebook, but not only that the thousands or parts that make your day to day like more entertaining, make it easier and generally just fit in without you even noticing.

There is something beautiful about a well written PHP application, the way it flows the way everything ties together, and the way user actions have been predicted and accounted for. Even in a nicely configured editor with syntax highlighting, looks like a picture to me, and the intricacy fascinates me. Reading other peoples well written code, will keep me tied to the screen until I manage to decipher every part of it. Anything that can engage you for as long as code can, and can have so much detail and can achieve so much can be nothing more than art.

Coding requires great skill, practice, patience and the ability to think out issues in so many different ways, it isnt something that everyone can do but it is something that some do with such beauty, that even if you only understood 1/10th of what was going on.

To me, my code is my art, and I suffer for it. I lay awake unable to sleep some nights as I try to think through a concept or how to achieve something I need to in an application I am writing, or simply trying to grasp an idea. Coding is something that piques your interest and in a way truly does envelope your life, you often find yourself thinking through a task on the computer and trying to come up with a way to simplify it, you end up spending 3 hours writing code to achieve something you could have done by hand in a mere few seconds and when you have finally finished that application, ground breaking function or class that you dreamed up in the middle of the night, you sit back, you appreciate what you have done, and in the Open Source world, you put it out there and you hope others appreciate it, much in the same manner as an artist puts their work out there.

Rate this:
2.4 (1 person)

The awaited full release of the Wordpress to Joomla converter is now here.

A simple GUI has been wrapped around each of the steps to make it a little more user friendly. However there is no GUI for the configuration of the converter, however this will be added in future versions of the converter, when further feedback is received, and bug fixes, enhancements and further conversion points are requested.

Simply as the requirements of the converter grow, so till will it’s features and user friendliness.

Download Wordpress to Joomla Converter Version 1.0

Please send in any feedback, bugs or enhancements and consider donating if you found the converter useful.

Rate this:
2.4 (1 person)

I wont go into too much detail here as to how we went about it, I simply do not have time today, and I know that people are awaiting this script.

I decided at the last minute to add comments to the import process, for the comment systems I chose both the Jom Comment module (Commercial and is integrated with the My Blog component http://azrul.com), and the Joomla! Comments module.

If you have other comment modules that you would like added to this list, please let me know and I will do my best to also write conversion for them. Personally if you can afford it I advise going with Jom Comments, it has a lot more to offer in general and is a lot cleaner all around.

With the content and comments import, there have also been some changes added to the config file. I have added settings for the batch import, the comment system you wish to import into and if you want comments added at all. The config file is first, then the content file.
I have not completed the database table clean-up at this stage, but I will be writing a GUI and clean system before actually releasing this as a full package, and at that stage will add the database clean-up.
Continue Reading ->

When I first took my steps into real web development and management, and started what could be called a serious site the Acronym CMS was something fairly new, well on a large scale it was new, but upon hearing this buzz word and looking into it, I immediately saw the massive benefit that this would provide me and my website.

So I entered into the market of websites driven by a CMS, for this I chose e107 and at that stage SEO and in fact search engines in general were something that just happened, however over the years I outgrew e107 and started switching to other systems. For one of my sites lpgconversions.org I made the switch from e107 to Joomla 1.0.13 within 2 months I had gone from barely ranking to the top ranks position for the key words “lpg conversions” and suddenly I realised what I had been missing out on with all my sites, and quickly changed the ones I was able to without to much pan over to Joomla and again my ranks soared and my income began to increase via Google Adsense and my other networks.

Many would have thought that this was the end of the story. However never being one content with the status quot and always wanting to improve on what I have in front of my, I continued to read up about the other Open Source CMS applications out their and their various benefits. Someone mentioned Wordpress as the leader, so I decided to test it out, and willing to take a profit hit I did so on lpgconversions.org, I went to the extent of making the URL’s match in order to keep continuity so that, on the next Google scan everything would appear similar apart from the platform.

A funny thing happened here, my ranking in no less than a week dropped from 1st position to 7th and the only change I had made was the platform serving my content. I was shocked, from all accounts I had read Wordpress should have boosted my ranking, I worked harder at it, placing all of the various SEO plugins, themes and changes advised by the learned fold of the internet in general, but no change that I made would fix my ranking, my profits took a massive plunge, I persisted for 1 month but just could not get things on track, and thus 1 month after the experiment began I rolled back to Joomla! 1.0.13 and again to my astonishment, my ranking shot straight back up to number 1, literally over night.

I have never been able to figure out precisely the cause of this plummet or the exact differences between the Joomla implantation and the Wordpress one, because to all intents and purposes they looked the same to Google.

You will notice however that I still use Wordpress for 2 of my sites, and am looking at adding a 3rd to that list, why? I hear you ask. Well to put simply, certain tools, suit certain trades, and in this case, Wordpress is second to none, for ease of use and true blogging power, done, right the SEO will increase, however for pure out of the box SEO and ranking power the 1.0.x series of Joomla has no equal, even Joomla 1.5 does not offer the same power.

So next time you are in the position to test, and are willing to toy with your rankings for a few days, I advise testing this, and if you manage to get better results than I did, please share them with us!.

Furthermore, in the future I plan to test further CMS options with the same above domain so that we have the same baseline and I plan on sharing them with you. If there are any options out there you would like tested, please let me know (And please point me at a converter so I wont have to build one) so that I can run the benchmarks for you.

Rate this:
2.5 (2 people)
6 Nov, 2008  |  Written by User ImageDan (Who am I?)  |  under Blog, Code Snippets, Tips and Tricks

I thought that i should touch quickly on recursion as it is something that is needed for the below tutorial on creating a conversion script for Wordpress to Joomla

Recursive functions, are functions that call upon themselves repeatedly, in the example in the previous post the function updateCategory is a recursive function

function updateCategory($category, $newParentID)
{
	global $db, $jb, $wp_prefix, $j_prefix;
	$children = $db->get_results("SELECT t.term_id as term_id, t.name as tname, t.slug as tslug, tt.description as description, tt.parent as parent FROM ".$wp_prefix."terms AS t INNER JOIN ".$wp_prefix."term_taxonomy AS tt ON t.term_id = tt.term_id WHERE tt.taxonomy IN ('category') and parent=".$category."  ORDER BY t.name");
 
	foreach($children as $child) {
		updateCategory($child->term_id, $newParentID);
		//Check if we are insterting into 1.5 or 1.0.x
		if($j_version=='1.5') {
			//Insert the latest category 
			$jb->query("insert into ".$j_prefix."categories (title, alias, section, description, published) Values('".$child->tname."', '".$child->tslug."', '".$newParentID."', '".$child->description."', 1)");
		}
		else
		{
			$jb->query("insert into ".$j_prefix."categories (title, name, section, description, published) Values('".$child->tname."', '".$child->tslug."', '".$newParentID."', '".$child->description."', 1)");
 
		}
 
		//
		// Insert into our temp storage/reference table
		//
		$jb->query("insert into jos_wp_category_map (wp_cat_id, jos_cat_id, jos_sec_id) values(".$child->term_id.", ".$jb->insert_id.", ".$newParentID.")");
 
	}
 
}

This function uses a recordset of data from the database, it then goes through each of the categories, sub-categories and inserts them in the database in a new level to it’s previous position, the function then calls itself again to check if the current record has children records.

This is a classic example of why recursion is useful and whilst not perfect coding, it does show the usefulness when you need to run a function for deep levels of information and in particular when you do not know how deep you need to go.

So to re-iterate, a recursive function simply calls itself multiple times.

I hope this helps and I hope you find new useful ways to use this, once learning recursive functions, it adds a whole new level to your coding and can cut the amount of lines of code you need to write in half.

Rate this:
2.1

In the first part of this series we looked at setting up the basics of the conversions script, config files, user imports and discussed the importance of planning each stage out and how to go about it.

In this section we will be looking at importing the categories from Wordpress into Joomla. You will be glad to know this part of the series should be a bit shorter to read. Though no less complicated, it is also the 3rd step of the conversion, and we only need to run the article import and the clean up after this.

One of the problems with the conversion is that Wordpress and Joomla, as you would expect do things differently, this is comes to light in the categories import and presents us with the first big decision of the entire import process. The problem is, that whilst in Wordpress all Categories can be a parent without a child, Joomla requires that you have both a section and a category.
This leads us to make the choice whether to create a single “placeholder” parent section, and then make all of our categories from Wordpress into Joomla categories, or whether to create all our Wordpress categories as Joomla sections and those without children, create a placeholder category under the section.
Finally, Joomla only allows for 2 levels, Section >> Category, whereas Wordpress allows, for children to be parent categories themselves giving a never ending hierarchy so we aren’t going to be able to have say “technology” >> “Apple” >> “iPhone” so we have yet another decision to make, we will either have to cut out the middle man, make the middle category section, or make them all sections with a generic “general” category beneath them.
In this case I have decided to include a function that will check the following:

  • If the category is a parent
  • If the category has children
  • How many children and levels it has
  • Restructures the categories, to either have child, to be child and brings them into a singular line

As such you will likely need to manage and change these through the Joomla Administrator UI after the conversion, as you may wish to get rid of some of the parents, (i.e. Technology >> Apple >> iPhone becomes Technology >> iPhone therefore either eliminating the need of the Apple category or making it obsolete in this example.

This scheme should work, it also means that each singular parent category is going to need a child, so lets say you had a category called “Foo”, we will then create a category under it called “bar” we will in this example however, name the category the same as the section, this will be somewhat confusing when you first look at it, however it at least maintains some sanity and continuance from your Wordpress set up.

If you want to make life easier it may be worth editing your category structure in Wordpress before the conversion this, will make life easier at the end of the day. We will no matter what repeat the section as a category, so it works in the same way as Wordpress.

I hope that wasn’t too confusing, it’s really quite simple, it’s just a matter of coming up with the correct or best worked solution for you. This is how I have decided is the cleanest way to operate and gives us a closer 1 to 1 relationship for Wordpress vs Joomla.

Finally I should mention that we will be making another “map” table which will give us a map of the categories again, so we can reference, the old category id and get the new category id, we will also record the section id, so we can drop all of the content into the content tables correctly.

So without further ado, her is the code.

<?php
error_reporting(E_ALL);
//
// Include The configuration file
//
include('config.php');
 
//
// Create a new connection to the Wordpress Database
//
$db = new  ezSQL_mysql($wp_db_user, $wp_db_pass, $wp_db, $wp_db_host);
echo "Initialised WP DB<br/>";
 
//
// Create a connection to the Joomla Database
//
$jb = new  ezSQL_mysql($j_db_user, $j_db_pass, $j_db, $j_db_host);
echo "Initialised JOS DB<br/>";
 
//
// Create a new table in your Joomla database to store the new 
// category and section ID's so that we can map posts and articles to them. We will destroy this table as one of the final steps
//
 
$jb->query( "CREATE TABLE `jos_wp_category_map` (`wp_cat_id` INT NOT NULL ,`jos_cat_id` INT NOT NULL ,`jos_sec_id` INT NOT NULL) ENGINE = MYISAM ");
echo "Created Category Map table<br>";
 
//
// This function iterates through the categories and children and updates the ID's
//
function updateCategory($category, $newParentID)
{
	global $db, $jb, $wp_prefix, $j_prefix;
	$children = $db->get_results("SELECT t.term_id as term_id, t.name as tname, t.slug as tslug, tt.description as description, tt.parent as parent FROM ".$wp_prefix."terms AS t INNER JOIN ".$wp_prefix."term_taxonomy AS tt ON t.term_id = tt.term_id WHERE tt.taxonomy IN ('category') and parent=".$category."  ORDER BY t.name");
 
	foreach($children as $child) {
		updateCategory($child->term_id, $newParentID);
		//Check if we are insterting into 1.5 or 1.0.x
		if($j_version=='1.5') {
			//Insert the latest category 
			$jb->query("insert into ".$j_prefix."categories (title, alias, section, description, published) Values('".$child->tname."', '".$child->tslug."', '".$newParentID."', '".$child->description."', 1)");
		}
		else
		{
			//Insert a matching Category for this top level category (now exists as Joomla Section and Category)
			$jb->query("insert into ".$j_prefix."categories (title, name, section, description, published) Values('".$child->tname."', '".$child->tslug."', '".$newParentID."', '".$child->description."', 1)");
 
		}
 
		// Insert into our temp storage/reference table
		$jb->query("insert into jos_wp_category_map (wp_cat_id, jos_cat_id, jos_sec_id) values(".$child->term_id.", ".$jb->insert_id.", ".$newParentID.")");
 
	}
 
}
 
//
// This query grabs all of the categories from the wp tables, wp stores categories in a taxonomy format, which essentially means that there
// is a multipurpose table which holds everything from categories, to tags, this consists of 3 tables in total, but we just want to grab information
// from 2 of them, term_taxonomy and terms. We could limit this query to grab only what we want, but I use the full query for anyone interested
// in seeing exactly what information is stored for category in Wordpress, more an FYI query than being specific and to the point, and does not harm
// since we will in 99% of cases be grabbing less than 1000 rows.
$categories = $db->get_results("SELECT t.term_id as term_id, t.name as tname, t.slug as tslug, tt.description as description, tt.parent as parent FROM ".$wp_prefix."terms AS t INNER JOIN ".$wp_prefix."term_taxonomy AS tt ON t.term_id = tt.term_id WHERE tt.taxonomy IN ('category')  and parent=0 ORDER BY t.name");
 
echo "<br/>Categories Selected from WP";
 
//
// Loop through the results array and work our magic
//
foreach($categories as $category) {
 
	//Check if we are insterting into 1.5 or 1.0.x
	if($j_version=='1.5') {
		// Insert the Parent Category into Joomla as a "Section"
		$jb->query("insert into ".$j_prefix."sections (title, alias, scope, description, published) values ('".$category->tname."', '".$category->tslug."', 'content', '".$category->description."', 1)");
		$newParentID = $jb->insert_id;
		//Insert the section as a category of itself
		$jb->query("insert into ".$j_prefix."categories (title, alias, section, description, published) Values ('".$category->tname."', '".$category->tslug."', '".$newParentID."', '".$category->description."', 1)");
	}
	else
	{
		// Insert the Parent Category into Joomla as a "Section"
		$jb->query("insert into ".$j_prefix."sections (title, name, scope, description, published) values ('".$category->tname."', '".$category->tslug."', 'content', '".$category->description."', 1)");
 
		$newParentID = $jb->insert_id;
		//Insert as a category to it's own section
		$jb->query("insert into ".$j_prefix."categories (title, name, section, description, published) Values ('".$category->tname."', '".$category->tname."', '".$newParentID."', '".$category->description."', 1)");
 
	}
 
	// Insert into our temp storage/reference table
	$jb->query("insert into jos_wp_category_map (wp_cat_id, jos_cat_id, jos_sec_id) values(".$category->term_id.", ".$jb->insert_id.", ".$newParentID.")");
 
	//Jump into the recursive function and update all of the subcategories and align them in a Joomla! style of section vs Category
	updateCategory($category->term_id, $newParentID);
 
}
 
echo "Category Import completed";
?>

The code above is not perfectly tuned but I ran out of time because work became exceedingly busy and I didn’t have the time to put in to refine the code to my usual standards. However it is functional and does the job we intended.

It inserts the category, grabs the first sub-category and inserts that, and then enters a recursive function in order to find each of the sub-categories of the first sub-category until it runs out of records to go through. This could be simplified to make the recursion hit immediately which i will do once I wrap this into a downloadable script, otherwise enjoy. The content will be following close on the heels.

Rate this:
2.1

I noticed during some routine coding today that I had made an oversight with the user import script, I apologise for this mistake but have provided the below update to the script.

<?php
error_reporting(E_ALL);
//
// Include The configuration file
//
include('config.php');
 
//
// Create a new connection to the Wordpress Database
//
$db = new  ezSQL_mysql($wp_db_user, $wp_db_pass, $wp_db, $wp_db_host);
echo "Initialised WP DB<br/>";
 
//
// Create a connection to the Joomla Database
//
$jb = new  ezSQL_mysql($j_db_user, $j_db_pass, $j_db, $j_db_host);
echo "Initialised JOS DB<br />";
//
// This function simply checks user permissions and then returns the correct one to the Joomla
// At some point we are going to need to get the ARO group id's as well but we can do that with another function
//
function check_user_perms($perm_string)
{
	//I am using an strpos search, which isn't ideal, we should use a regular expression but that is for another tutorial
	if(strpos($perm_string, "subscriber")!==false)
	{
		//we have a subscriber
		$perm = "Registered";
	}
	else if(strpos($perm_string, "author")!==false)
	{
		//we have an author
		$perm = "Author";
	}
	else if(strpos($perm_string, "administrator")!==false)
	{
		$perm = "Super Administrator";
	}
	else if(strpos($perm_string, "editor")!==false)
	{
		$perm = "Editor";
	}
	else if(strpos($perm_string, "contributor")!==false)
	{
		$perm = "Publisher";
	}
 
	return $perm;
}
 
//
// This function just maps the group the user is in with the ARO group ID
//
function aro_acl_group_id($group)
{
	switch ($group) {
	case "Registered":
		$g_id = "18";
		break;
	case "Author":
		$g_id = "19";
		break;
	case "Super Administrator":
		$g_id = "25";
		break;
	case "Editor":
		$g_id = "20";
		break;
	case "Publisher";
		$g_id = "21";
	}
 
	return $g_id;
}
 
//
// Create a new table in your Joomla database to store the new 
// User ID's so that we can map posts and articles to them. We will destroy this table as one of the final steps
//
 
$jb->query( "CREATE TABLE `jos_user_map` (`wp_id` INT NOT NULL ,`jos_id` INT NOT NULL) ENGINE = MYISAM ");
echo "Created User Map table<br />";
 
 
//
// Select the users and their related meta details from Wordpress
// The query looks complicated, but all it does is applies some easy names to each column selected for handling later, it also join the usermeta table and grabs the "capabilities" field
// which tells us what permissions the user has
$users = $db->get_results("select u.ID as wpID, u.user_login as username, u.user_pass as pwd, u.user_email as email, u.user_registered as reg_date, u.display_name as display_name, um.meta_key as mkey, um.meta_value as u_perm
from ".$wp_prefix."users u
join ".$wp_prefix."usermeta um on um.user_id = u.ID
Where um.meta_key='wp_capabilities' order by u.ID");
 
echo "Selected WP Users and beginning insert loop";
//
// Declare the $i integer simple for a count later
//
$i=0;
//
// Loop through the results array and work our magic
//
foreach($users as $user)
{
	//
	// It's sometimes a good idea when throwing in usernames to run some checks and remove any invalid characters, or at least invalid for the new system
	// Luckily Joomla and Wordpress were both written with a great deal fo security in mind and as such, we don't need to write any RegExp to check
	// and remove anything, but if you were coming from a system like e107 it is VITAL that you remove characters like ' from usernames as not only
	// will this cause problems in Joomla, such characters can open you up to SQL injections. But once again we don't need it here.
	//
 
	//
	// First things first, lets see what user they are and then do the mapping.
	//
	$user_perms = check_user_perms($user->u_perm);
 
	//
	// Get ARO Group ID for Joomla
	//
	$aro_group = aro_acl_group_id($user_perms);
 
	//
	// we are ready to start importing users
 
	// Insert the basic user Profile information into the Joomla User table (you may want to change the "display name" to "wp: nice_name" both in the qp query and here
	$jb->query("Insert into ".$j_prefix."users (name, username, email, password, usertype, sendemail, gid) VALUES ('".$user->display_name."', '".$user->username."', '".$user->email."', '".$user->pwd."', '".$user_perms."', 0, ".$aro_group.")");
 
	// Get the ID and store it
	$new_user_id = $jb->insert_id; 
 
	// Use the new User ID to insert into our conversion table so that we can match ID's for the articles
	$jb->query("insert into jos_user_map (wp_id, jos_id) VALUES (".$user->wpID.", ".$new_user_id.")");
	// Insert into the first ACL table, Core ACL
	$jb->query("Insert into ".$j_prefix."core_acl_aro (section_value, value, name) VALUES ('users', ".$new_user_id.", '".$user->username."')");
	// get the aro_id
	$aro_id = $jb->insert_id;
	// Insert into the ACL Groups table
	$jb->query("insert into ".$j_prefix."core_acl_groups_aro_map (group_id, aro_id) VALUES (".$aro_group.", ".$aro_id.")");
	$i++;
}
 
echo $i." records inserted<br /><br /><br />";
 
echo "User Import Complete";
 
//
// TO DO: Add the link to import the next step, categories
//
 
?>

The issue was that during the final insert query, I inserted the user ID into the group_aro_map when I should have inserted the newly created aro_id.

It is a quick fix, we simply grab the newly inserted id via the insert_id; call, place it in a variable and use it for the insert, all the action is seen below

	// get the aro_id
	$aro_id = $jb->insert_id;
	// Insert into the ACL Groups table
	$jb->query("insert into ".$j_prefix."core_acl_groups_aro_map (group_id, aro_id) VALUES (".$aro_group.", ".$aro_id.")");

Sorry again, this should now work fine and the category import script is coming up next.

Rate this:
2.1
28 Oct, 2008  |  Written by User ImageDan (Who am I?)  |  under Blog, Conversions, Tips and Tricks, Tutorials

I wanted to just reach out to let you know the second part of the script and tutorial on converting from Wordpress to Joomla is in the works, I am only managing about 5 minutes a day working on it but am at the stage where I am writing the major parts of the code.

Whilst it seems fairly simple to write a category importer, Joomla and Wordpress manage categories in very different ways. Wordpress also allows for an infinite level of categories, whilst Joomla restricts you to Section and dingle category hierarchy. This presents a fairly complex set of problems and it means a lot of work in order to sort out and create a new structure that still makes some sense and holds true when we move to Joomla.

On the surface it isn’t a complex problem but as the developer we have made some pretty harsh decisions on behalf of the people that will be using the script to convert their systems, it also means that we have to do some lateral thinking about how we are going to progrematically take something that may be a hierarchy of “foo >> Bar >> doe >> Ray” into something like “Foo >> Ray” or “doe >> Ray” essentially we cant make everyone happy and we are going to have to make some people happy and others unhappy. I plan on writing a switch into the converter also, that allows a site administrator to say they want it to work so that any parent, no matter it’s place in the hierarchy becomes a section as well as staying a child, this allowing for everyone brings drama of it’s own though!

Stay tuned
Dan

Rate this:
2.1