Postita vastus 
 
Teema reiting:
  • 0Hääli - 0 keskmine
  • 1
  • 2
  • 3
  • 4
  • 5
Kuidas kolida Drupal WordPressile
12-07-2008, 02:15 PM
Postitus: #1
Kuidas kolida Drupal WordPressile
Ehk leidub siin mõni kasutaja, kes sooviks oma Drupalil baseeruva lehe üle kolida WordPressile. Ise olin üks sellistest, kes kunagi laustas Drupalil baseeruvate lehtedega ja siis on järk järgult need üle kolinud WordPressile.
Järgnevalt üks lühike õpetus, kuidas üle kolida Drupalilt kõik postitused ja kommentaarid WordPressile.

* Esmalt - tehke WordPressi abil oma Drupali andmebaasist koopia
* Looge uus andmebaas - näiteks drupalmigration
* Paigaldage uus ja puhas WordPress. Paigaldage ta näiteks andmebaasi wordpress
* Nii wordpress kui ka drupalmigration peavad omama sama kasutajat!
* Nüüd käivitage järgnev SQL skript phpMyAdminnis - enne kontrollige üle oma andmebaaside nimed ja eesliited (vaikimisi eesliide WordPressil on näiteks wp_)

PHP kood:
# this script is modified after the recipe provided at
# http://spindrop.us/2006/05/19/migrating-from-drupal-47-to-wordpress
#
# as modified by:
# http://www.brendanloy.com/2007/02/wordpress-21-upgrade-problems.html
#
# and updated elegantly by:
# http://www.darcynorman.net/2007/05/15/how-to-migrate-from-drupal-5-to-wordpress-2/
#
# ...and then hacked to pieces and reassembled clumsily by Alan Dove,
# who can be found at http://dovdox.com
#
# this assumes that wordpress and drupal are in separate databases
# and that the wordpress database is named wordpress, while the
# drupal database is called drupalmigration.
#
# Finally, note that this script will not preserve posts' categories
# anymore - it will only move the posts and comments themselves.

# first, nuke previous content in wordpress database
use wordpress;
delete from wp_posts;
delete from wp_comments;

# posts
INSERT INTO
    wp_posts 
(idpost_datepost_contentpost_title,
    
post_excerptpost_namepost_modified)
SELECT DISTINCT
    n
.nidFROM_UNIXTIME(created), bodyn.title,
    
teaser,
    
REPLACE(REPLACE(REPLACE(REPLACE(LOWER(n.title),' ''_'),'.''_'),',''_'),'+''_'),
    
FROM_UNIXTIME(changed)
FROM drupalmigration.node ndrupalmigration.node_revisions r
WHERE n
.vid r.vid;

# comments
INSERT INTO
    wp_comments
    
(comment_post_IDcomment_datecomment_contentcomment_parentcomment_authorcomment_author_emailcomment_author_url)
SELECT
    nid
FROM_UNIXTIME(timestamp),
    
commentthreadnamemailhomepage
FROM drupalmigration
.comments ;

# update comments count on wp_posts table
UPDATE `wp_postsSET `comment_count` = (SELECT COUNT(`comment_post_id`) FROM `wp_commentsWHERE `wp_posts`.`id` = `wp_comments`.`comment_post_id`);

# fix post slugs. first we have to remove the duplicate _____ chars, then replace that with a single - char
UPDATE wp_posts set post_name REPLACE(post_name'__''_');
UPDATE wp_posts set post_name REPLACE(post_name'__''_');
UPDATE wp_posts set post_name REPLACE(post_name'__''_');
UPDATE wp_posts set post_name REPLACE(post_name'__''_');
UPDATE wp_posts set post_name REPLACE(post_name'_''-'); 


Kui see on ilusti tehtud, siis jääb veel üle natuke mängida .htaccess failiga. Põhjus lihtne - selle abil on võimalik tööle jätta kõik varasemad Drupali kodulehele tehtud viited. Kui see pole oluline, siis võite selle sammu ka vahele jätta. Vahetage sinuwordpress.com link oma domeeniga.
PHP kood:
#
# Apache/PHP/Drupal settings:
#

# Various rewrite rules.
<IfModule mod_rewrite.c>
Options +FollowSymlinks
RewriteEngine on

# Rewrite drupal urls to worpress
RewriteCond %{QUERY_STRING} ^q=node/(.+)$
RewriteRule ^(.*)$ http://sinuwordpress.com/?p=%1 [R=301,L]

# Forward RSS feed
RewriteCond %{QUERY_STRING} ^q=rss.xml$
RewriteRule ^(.*)$ http://sinuwordpress.com/?feed=rss2 [R=301,L]
RewriteCond %{QUERY_STRING} ^q=atom/feed$
RewriteRule ^(.*)$ http://sinuwordpress.com/?feed=rss2 [R=301,L]

</IfModule

Ja ongi kõik....
Leia selle kasutaja kõik postitused
Tsiteeri seda postitust oma vastuses
Postita vastus 


Vali alamfoorum:



Võta ühendustSinu VeebiabiTagasi ülesTagasi sisu juurdeLihtsustatud versioonRSS voog