Home

Primary links

  • top o the deck
  • Drupal for Beginners
  • about
  • links
  • give me some sugar

Drupal stuff

  • EDAM
  • STARDOM
  • Question Bank
  • Drupal musings
  • Drupal tips
Home

Key stuff on this site

Easy Drupal Admin Manual (EDAM)

SEO, Traffic and Revenue: Drupalace's Online Manual (STARDOM)

Drupal for Beginners

Subscribe to posts by RSS or email

Subscribe to Drupal Ace by RSS feed RSS feed 

Subscribe to Drupal Ace by Email

Donate towards my web hosting bill! Get a great host!

Share and save

Share/Save

Random piece of content

!How to hide a node title?

Manuals on this site

  • Easy Drupal Admin Manual (EDAM)
    • Welcome to Your Site
    • First Steps: Please Read!
      • Understanding These Instructions
      • Important Terminology!
      • Best Practices for Site Admins
    • Super Quick Guide (for the experienced and the brave)
    • Logging In
    • Your Administrator Tools
    • Setting Site Basics
      • Setting Site Information
      • Configuring Your Theme
    • Creating Content
      • Node Types
      • Create a Page Node
      • Create a Story Node
      • Create a Blog Entry Node
      • Making Images and Other Files Available
      • Using Text and Image Editors
    • Organizing Your Content
      • Terms, Vocabularies, and Taxonomy: "Tagging" Your Content
        • Taxonomy Suggestions
      • Menus, Links, and Paths: Navigating the Site
        • Content Paths and URLs
        • Creating Links
        • Working with Menus: Administration Form (Drupal 6)
        • Working with Menus: Administration Form (Drupal 5)
        • Creating Menu Items on the Fly
        • Placing Menus on Your Pages
      • Placing Content on pages
        • Creating a page from a Single Node
        • Creating a page from a List of Nodes
        • Setting the Front Page
      • Working with Blocks
    • Maintenance Stuff
      • Maintenance and Construction Notices
    • Other Fun Things
      • Changing Color of Garland Theme
      • Free Aliases!
  • SEO, Traffic and Revenue: Drupalace's Online Manual (STARDOM)
    • Set a Clear Goal
    • Make a Good Site
      • Put out the Welcome Mat
      • Make Great Content
      • Build a Great Brand
      • Make Navigation Easy
      • Tune Site Performance
    • Drive Traffic
      • Promote your Site
      • Get Found with SEO
    • Build a Community
      • Build an Offsite Community
    • Monitor and Improve
    • One-Page Checklist
    • Drupal and the Blogging Starter Checklist
      • Drupal and the Blogging Starter Checklist, Part 1
      • Drupal and the Blogging Starter Checklist, Part 2
      • Drupal and the Blogging Starter Checklist, Part 3
      • Drupal and the Blogging Starter Checklist, Part 4
      • Drupal and the Blogging Starter Checklist, Part 5
      • Drupal and the Blogging Starter Checklist, Part 6
      • Drupal and the Blogging Starter Checklist, Part 7

Recent comments

  • It worked

    adding $GLOBALS['tempUser'] = $user; worked but I find it worth noting that I had to delete...

  • very good document...

    very good documentation for beginners!!!!!! thanks!!

  • del penitential 62

    strike out abject
    eliminate penitent 5

  • Chat

    Thank you a lot about very beneficial to my work was very useful thank you

  • Drupal Resources f...

    I would start learning from the "Diving In" section above. That links to the good beginners'...

more

How to change a node's type?

Submitted by Drupalace on Sat, 2007-12-15 00:05
  • Drupal
  • answered question

Hide your eyes, conservatives: it's a node-change operation, the shocking switch from Blog Entry to Page, or Story to Review, whatever your desires demand. Call it a miracle or call it a travesty, modern Drupal science makes it possible... and seductively easy.

Question answer: 

I'll answer this question as quickly as I ask it – because I just tested it out while moving Drupally questions of various breed into a single node type on this site, the node type called "Drupal Questions" I created for my Question Bank. (It's a nice CCK-created node type with fields for the question, for the answer if available, and for a related URL.)

I had an old blog entry on a certain Drupal puzzle, and thought that node should be reworked into a Drupal Question. I was prepared to simply copy its content into a brand new node. But lo, that blog entry had a couple of comments, and I'd hate to lose those. How would I also move the comments from the old node to the new node I'd be creating? I dunno.

Hmm, a better idea: instead of making a new node, how about transforming the old blog entry node into a new type? I seemed to recall a module claiming that transfigurational wherewithal...

And here it is: Nodetype. http://drupal.org/project/nodetype

I downloaded the module and, before touching anything else, backed up my site database! That done, I installed Nodetype. It offers no admin options, and only shows up when you edit a node: you see a simple drop-down list of node types into which you can change the current node (complete with nice warning to only change the node type if you "know what you are doing"!)

In my case, I selected my custom node type "Drupal Questions" from the list. Doing a Preview of the node showed no changes, but hitting Submit put the change into effect. It worked great, and – the thing I was most hoping for – left the node's comments attached and intact. Nodetype, you swinging switch-hitter, you're all right by me!

You can see my results here:

http://www.drupalace.com/blog_entry_trick_bin_hiding_node_title_2007_07_03

That node was a Blog Entry but is no longer; only its URL alias hints at its original configuration. (Kind of like the Adam's apple on "Lucy" in that Phuket night clu... no, the Ace is speaking too much here. Full stop.)

Now, I haven't used Nodetype enough to give out any handy tips, but the following safety procedures would seem wise:

1) Back up your database before dabbling in node DNA like this.

2) Your target node type may have different fields from your original node type, and I would imagine that data gets lost when a field gets dropped. Copy all major text field data from your original node before changing its type, to avoid loss.

3) Experiment first with a dummy node, if you really want to be safe before operating on the real thing.


If you've ever agonized over what node type to use for some piece of content, worried about getting "stuck with" the wrong decision, you can relax a bit with Nodetype in your arsenal. Bring out the tranny in your nodes! Good stuff.

Share/Save
  • Printer-friendly version
santa's picture

Nodelist enhancement?

Submitted by santa (not verified) on Mon, 2010-03-15 22:22.

Seems to me info can be lost where the two node types are different in more than name.

I think it would be useful if one could see a comparison of the fields of the old and new node types. I came here because I misconfigured freelinking, and had the default new document type set to "story" where I intended "wiki." I don't think the differences are great, but they might be significant. And, from this description, nodelink will do its thing and all might seem good when, in face, not all is good.

 

 

  • reply
Drupalace's picture

Node type change and risk

Submitted by Drupalace on Wed, 2010-03-17 13:34.

Indeed, letting an automated procedure change a node's type does sound like a risk of data loss, especially if the two types' fields don't match. If the source type has more fields than the target type, do those extra fields simply get stripped off and their data lost forever? I don't know!

Your suggestion is a good one: It'd be great if the module displayed a pre-change list of what changes it will make. As it is, the workings are a black box. So for now, all I can suggest to users of Nodetype is: Make sure the target node type has all the fields you want to keep from the original type (and that those fields share the same field names); test the procedure on a dummy node or two before hitting the real nodes; and, ABSOLUTELY back up that database before letting Nodetype touch a thing! 

With those precautions taken, I've found it a nice tool.

Thanks for the comment!

  • reply
Unknown Drupaloid's picture

Re: How to change a node's type?

Submitted by Unknown Drupaloid (not verified) on Fri, 2008-04-04 19:47.

the nodetype.module comes quite handy thanks to the developer. it would be perfect though, if its part of the content bulk actions + a feature for cck per field operation.

  • reply
cellmaker's picture

Re: How to change a node's type?

Submitted by cellmaker (not verified) on Wed, 2008-01-30 02:01.

I was curious if this could also be done by poking the database directly to change, say, nodes of type "blog" into nodes of type "question" (a custom content type)?

Oh, the danger.

Charlie

  • reply
Drupalace's picture

Re: How to change a node's type?

Submitted by Drupalace on Wed, 2008-01-30 11:13.

Ah, the hubris of a Frankenstein! Actually, I would think it's quite possible to manhandle the database directly, as you suggest. In fact, what else could the nodetype module be doing, but performing some database surgery that one could also perform manually?

I don't know what the SQL commands would be; I expect that dissecting the nodetype module would yield clues. I've got too much on my to-do list, so for now will stick to letting nodetype do the heavy gravedigging for me. But who knows, maybe some night when the moon is full and the Van de Graaf spheres are crackling, it'd be illuminating to strap down a node and take scalpel in hand...

 

  • reply
Unknown Drupaloid's picture

Re: How to change a node's type?

Submitted by Unknown Drupaloid (not verified) on Fri, 2008-04-04 23:00.

I just had a first look at this module. It seems that its only task is to change the type. And because the module is doing that not directly by modifying the database but using ordinary drupal functions the cache will be updated probably.

As far as I can see the module (implicitly) does:

update node set type='NEWTYPE' where nid=NODEID;

(where NEWTYPE is one of the values in table node_type column type: select type from node_type; )
And the node should also be moved from table content_type_ to content_type_

Now some thoughts about what can be done to extend the nodetype module

When you have an node (NID) of type 'image', there is always one image attached to it.
Name and path of this image is stored in table 'files'. When you have versioning activated (VID) a query to pick up the image will look like:


select f.fid, n.nid, filename, filepath from node n, file_revisions r, files f where n.vid=r.vid and r.fid=f.fid and n.nid=NID;

You can see that the image module has created several additional derivative images with names (column filename) as
thumbnail
preview

If you want to change the node type from 'image' to 'story' all the derivative images (all filenames but '_original') can be purged.
The '_original' image can be attached to the story if there is e.g. a CCK field of type image. To check this try


select type_name, widget_type from node_field_instance where type_name='story' and widget_type='image';

Column type_name will show (all) CCK field name of type 'image' attached to node of type 'story'. It looks like
'field_attach_image'

where attach_image is the name for the field used when the CCK field was set up.
Prepending this type_name with 'content_' yields to
'content_field_attach_image'

which is the name of the table to put the image in:
insert into content_field_attach_image values (VID, delta?, NID, FID, '', '');

I hope this helps somebody
Regards
Schildi

  • reply
Drupalace's picture

Re: How to change a node's type?

Submitted by Drupalace on Wed, 2008-04-09 23:57.

I can't help but think it'll help somebody! I pitch this page on the drupal.org forums whenever someone asks about changing a node type, so I'm certain future seekers of transformational knowledge will see your post and learn. Thank you, Schildi!

 

  • reply
Unknown Drupaloid's picture

Re: How to change a node's type?

Submitted by Unknown Drupaloid (not verified) on Wed, 2008-03-05 03:39.

wow, thanks for posting this. i wanted to do it, but searching google didnt bring up very good results.

you rocked it tho

  • reply
Drupalace's picture

Re: How to change a node's type?

Submitted by Drupalace on Wed, 2008-03-05 23:05.

Glad it helped! Thanks, and drop by any time.

  • reply

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd><br><p>
  • You may quote other posts using [quote] tags.
  • Lines and paragraphs break automatically.
  • Web page addresses and e-mail addresses turn into links automatically.

More information about formatting options


Relevant Content

The Drupal Ace logo has dealt these content suggestions from the deck.

  • Working with Menus: Administration Form (Drupal 6)
  • Drupal beginner documentation picking up steam
  • Working with Menus: Administration Form (Drupal 5)
  • Updating Easy Drupal Admin Manual
  • Drupal for Beginners
  • Why would Color-enabled themes work for all sites but one?
  • Limiting node access: three quick'n'easy tools

Learn Drupal, hands-on

Get the beginner-friendly ebook that teaches community site building via a live case study.

Drupal 6 Ultimate Community Site Guide

Read the review

Drupal mini tip

Site visitors seeing your ugly error messages on the screen (along with details of your Drupal installation path)? Once your site goes from dev to launch, you probably want to have errors recorded in the log but not splashed across the screen. Head to the handy Error Reporting settings found at admin/settings/error-reporting. 

It's a deal!

Dreamhost dealsDrupal Ace presides over his domain, proudly ensconced in his DreamHost eyrie. Won't you join me?

Promo code deal!

Just enter the code 49ER when you register for an account, and save $49 off the already-low price. No strings!

Read my hosting service review

Powered by Drupal, an open source content management system

Copyright 2007 and forever after. Made with Drupal, of course. On OS X, of course. Served up by DreamHost. DreamHost

RoopleTheme