By Marc Bijl on
This week I installed drupal 5.1, imported a 4.7 database and upgraded the database with update.php to 5.1. So far so good :)
Since it's possible to define custom content types in drupal 5.0, I was wondering if I can change the content type of existing nodes by manually changing the type field (in the node table). Why? Because in my situation, converting certain nodes to another type makes more sense (in a functional way), and they make it possible to change themes (by assigning specific page templates to nodes of a certain type). Just some thoughts...
Does anyone know where I can go wrong?
Comments
Anyone?
___________________
discover new oceans
lose sight of the shore
Changing node type
I've done this many times in the database in a 4.7 installation, though not in a 5 installation. I don't think you'll have much of a problem, but as always, back up your database before you do it.
Same thoughts...
Hmm, that's what I thought too. Should be safe when applied to standard types, like blog, story, page, et cetera. I just think it's necessary to be careful when changing the type of flexinodes, or nodes that are based on a type with a specific table (webform?).
Thanks for the reply!
___________________
discover new oceans
lose sight of the shore
If it's safe to assume that
If it's safe to assume that things won't go wrong (I'll do it on a test site first of course) - I have a follow-up question. What if you wanted to change all nodes of a specific taxonomy category (not just terms, the entire umbrella category, that is the "vocabulary") to be of another content type, for the same theming and possibly easier searching reasons?
Since the content type is stored in node, where there is no field for tid's and "vid" is not the same as the vocabulary id called "vid" in the table vocabulary, and the tid is stored in term_data - this gets a little confusing. Anyone have any brights ideas?
Nevermind, I did some dumps
Nevermind, I did some dumps to find the nodes I wanted o change (sorted by which topic) they were and did so.
However, now I can't edit any of these nodes, instead I get this:
warning: call_user_func_array() [function.call-user-func-array]: First argument is expected to be a valid callback, 'commercial_node_form' was given in /home/html/etc/drup/includes/form.inc on line 217.
oh I see, I misspelled the
oh I see, I misspelled the node type name. Do'h!
timing is everything!
I've just arrived at the same conclusion for a site I'm working on, and here you've just done it! Is everything working ok since the changeover?
-------------------------------------------
Interactive Worlds and Immersive Obsessions
http://www.asifproductions.com
-------------------------------------------
Interactive Worlds and Immersive Obsessions
http://www.asifproductions.com
Yeah everything is working
Yeah everything is working fine *knocks on wood, spits three times* ;P
did it, no problem
I've just changed a bunch of nodes to another type using sql, and everything still works perfectly.
Just change the 'type' field to the new content type.
How?
I am an absolute SQL Doofus, could anyone please explain how to change the node type? I got as far as this in CPanel... but how do I actually change the values?
Thanks!
How?
Old thread, but in case anybody else is wondering:
The SQL code would be:
--to change one node of given NODEID
UPDATE `node` set `type`="newtype" where `nid`=NODEID;
*or*
--to change all nodes of given OLDTYPE
UPDATE `node` set `type`="newtype" where `type`="oldtype";
I'd highly recommend checking the fields used by your content types first to make sure nothing important is dropped. Also note that the type is not the Name of your node type, but the Type, and is case sensitive.
See also:
http://www.drupalace.com/questions/how_change_nodes_type