Okay. First
alpha version done. The forum wouldn’t let me upload the .zip file, so you’ll have to download it instead:
http://www.smalldog.be/sandbox/wp2modx.zip
Some notes:
1) This is alpha. Alpha, alpha, alpha. I’ve only tested it on my own blog. Use at your own risk. For me, it works.
2) This is NOT a snippet. It’s a separate PHP script that doesn’t integrate into ModX at all (at the moment).
3) Since it’s alpha, and since it’s made mostly for my own use, it’s rough and ready. You shouldn’t need any particular knowledge of PHP to run it, but you will need knowledge of how to edit a text file, and decent knowledge of how your WordPress database is set up. If you’re familiar with phpMyAdmin or another web-based mySQL database management tool, you’re definitely good to go.
4) Feedback very welcome. I’m sure I’m not the only person who needs/wants this functionality, so with some fine tuning and community help, maybe it could be made user-friendly and more automated.
Copy/pasted below is some information from the script itself. Please read through it before using the script:
/* INSTRUCTIONS
*
* 1. Fill in the Configuration section variables (below).
*
* 2. Upload this script to the webserver on which your WordPress
* mySQL database is located.
*
* 3. Access the wp2modx.php script via your webbrowser. (I.e. if you
* uploaded it to www.domain.com/mysite/wp2modx.php, then go to
* www.domain.com/mysite/wp2modx.php in your webbrowser.)
*
* 4. If the script is able to run successfully, it will create a new
* file in this same directory called "wp2modx_import_data.txt"
*
* 5. Access your ModX mySQL database (generally via phpMyAdmin or such).
*
* 6. Use an 'import' function to import the data of the wp2modx_import_data
* file.
*/
/* ASSUMPTIONS
*
* This script was created with particular assumptions in mind:
*
* 1. That you have two (or three) ModX template variables _already_ created:
*
* 'tags': used to store WordPress tag information.
* 'categories': used to store WordPress category information.
* 'keywords': used to store All-In-One SEO keyword information. (With AIOSEO only)
*
* You will need to know the _ID number_ of these template variables in ModX.
* The ID numbers can be seen in the ModX Manager panel, under the
* "Elements" => "Manage Elements" => "Template Variables" section.
*
*
* 2. All documents which are migrated are assumed to belong to the same, single author.
* (That is, we assume WordPress is a one-person blog.) This author is assumed to
* be the main administrative user of ModX (userid "0").
*
* Functionality to migrate content to multiple users can likely be added later.
*
*
* 3. That you will manually transfer/import the resulting text file to the
* ModX database. Most MySQL databases will only allow connections from the
* localhost. Thus, if your WordPress and ModX installations are on different
* webservers, this is an absolute necessity.
*
* The script could be modified to do the entire migration automatically,
* if the WordPress and ModX installations are on the same server. I haven't
* done that.
*
*/
/* IDEAS FOR FUTURE VERSIONS
*
* - Do not process WordPress posts in certain categories / with certain tags
* - Automatically migrate content if WP and ModX share the same server.
* - Create ModX Template Variables if they are not already present.
*
*/
/* CLOSING NOTES
*
* - This script will not process WordPress posts which have the post_status
* 'inherit'. These are revisions, and ModX Evolution 1.0.0 does not
* support version control as of this writing.
*
* - Relative links and URLs (for images, etc.) _may_ break.
*
* - I'm a self-taught programmer and don't do OOP. As such, the program
* could probably be vastly improved regarding modulization and OOP
* techniques. But it works.
*
*/