I recently came across an excellent Drupal 6.x module called Flexifield.

Flexifield allows you to use an existing content type as a "template" for a custom field group on another content type. This makes it easy to nest content types and really improves usability when adding and editing nodes with references.

For example, if you wanted to have a content type called "book" which will have the ability to associate unlimited "book pages". The old way would be use a node reference field that allows you to choose an already existing page in the system.

The Old Node Reference Way:

Step 1: Create the book page

Step 2: Edit the book and choose the book page to reference

Now this is all fine and dandy if you want your book page content type to be able to stand on its own, have it's own url, be referenced by multiple books, etc.

But what if you know that each book page will be unique to it's parent book? It will be pretty annoying to have to keep creating each page manually ahead of time so you can reference it. This is where Flexifield comes in to save the day. The module will allow you to create content "on the fly" within an existing content type, and still give you the ability to edit, delete and change ordering!

We simply enable flexifield, and choose it as the cck widget when we add the field for our book content type.

The Flexifield Way:


Pretty slick huh? Notice the "add another item" option at the bottom. This will allow us to add unlimited book pages on the fly, all from the main book edit page!

Some things to note:  When you add a book page with flexifield, this does not actually create a book page node, it just used the book page content type as a template to store the cck fields on our parent content type. All of the field information is stored directly in the parent book node object. The other thing to remember is that the book page content type is going to remain on the content creation screen, even though we do not use it directly. My suggestion is to hide it with some jquery so you do not end up confusing your content editors. I hope this post was helpful in getting you up and running with flexifield!