I’m trying to export Drupal posts over to WordPress (which is in itself a hassle). I can’t figure out how to maintain the URLs of the blog posts though. Some of them are customized:
Blog titled Story of Soil is blog/2012/03/03/soil-story
in Drupal. One titled Welcome John Doe is simply /john
Is there a Drupal function to making these URLs? Where does it store the customized blog posts?
You can get the URL Alias by using the
url
method.You should be able to get the Alias for a node by using
drupal_lookup_path
:Drupal manual: drupal_lookup_path or the reverse, look up node/internal path from alias: drupal_get_normal_path.
It seems the url function function that Rawkode posted does about the same, so I guess it comes down to your personal preference.
Also see: http://daipratt.co.uk/how-to-get-the-path-of-a-node-from-the-node-id-in-drupal/
I found the above tremendously helpful because i was hoping to get what I needed from the db when I was looking and not by using a function. it gave me a good starting point but running this as it sits does nothing but error out because those are not the right column names. Keep in mind this updates stuff in place and will break everything if you are not working on a copy of the database. This code will fix it:
since im not big on doing things in place I just added two columns nid and slug and then ran this query
I found the url_alias table in the Drupal database, and I ran this SQL statement:
src is now the nid and dst is now the slug. I can rename them and then
INSERT INTO wp_posts
aspost_name