Drupal 7: Node Convert Module

David G - DrupalAs my current project is wrapping up…  my clients have last minute change requests. In this project the site is moving from Drupal 6 to Drupal 7. In the past the website had a Drupal Book content type that had a Graduate Program Handbook for prospective students entering a college’s graduate program. In moving to Drupal 7 the client had many change requests. During the final last minute changes of the website I was able to install and play with the Node Convert module. 

Problem

During the final approval and release of this project the client had the following last minute requests:

  1. Remove the Drupal 6 Graduate Handbook
  2. Replace the 28 page handbook with a simple PDF file uploaded to the server.
  3. Bring back the on-site handbook but update it to the new PDF file contents and make sections of the handbook a single drupal node per section. The old site had multiple subsections per major section. For example:
    • Section 1: Applicants
      • Section 1.1: Prerequisites
      • Section 1.2: Forms
      • Section 1.3: Methods of Submission
        • Section 1.3.1: Digital uploads
        • Section 1.3.2: FAX
        • Section 1.3.3: Mail
  4. For book pages show a menu of the book index when viewing any book node in the Right Sidebar of the theme.

These requests came at a final wrap-up meeting for the project with the website visible on a QA (quality assurance) demo server, and accessible only to the client by password. This project was initially built using Drush as a migration tool I dont really want to script these changes to Content on the website.

Using Node Convert

I’ve used the Book module in the past a number of time; but I feel I’ve not discovered the full potential the module. Since the client wanted a single Section per node of the Handbook the idea is to configure Drupal to:

  1. Store a handook page as a Node.
  2. somehow apply the book index to every book page.
  3. support sub section linking (Anchor links) in the book outline index.

Of all these requirements item (3) is not easily supported by the book module out of the box. So ideally a custom Menu will hold the book items and by using Special Menu Items we can support Anchors within handbook sections without needing to create a Node per subsection.

So I debated using simple Pages in Drupal and a custom Menu for these pages to create our much simpler book-like Drupal feature. Our new “book” would only be 18 pages in length …. if only I could easily migrate existing book nodes to page node content type.

The Node Convert module allows us to easily do this on a live site. A programmatic alternative to this approach could be to use our trusty Migrate module — but I’m “done” with the project and just want to bang this out!

To change existing book content into page content we follow these simple steps:

  1. Install the module, as any other contributed module.
  2. Then within the Node Convert admin UI you must create a template for the data you will be moving (meaning map the fields between 2 content types). These templates are applied between 2 existing content types.
    Node Convert UI to create a new conversion template.

    Node Convert UI to create a new conversion template.

    Step 2 of the Node Convert UI, define the field mappings of the content.

    Step 2 of the Node Convert UI, define the field mappings of the content.

  3.  The Admin UI provides a listing of templates between convertable content types that you’ve previously assigned. Since I’m working with basic Book and Page content types in Drupal I created a set of templates that let me test moving content from a Page to a Book, or from a Book to a Page:

    The Node Convert UI provides a full listing of known content conversion templates.

    The Node Convert UI provides a full listing of known content conversion templates.

  4. After you have your conversion templates setup you can goto the Admin -> Content screen, select the content you want to convert and select your new conversion action you’ve created. The Batch API then converts your data:

    Example output of successful conversion from Book to Page nodes.

    Example output of successful conversion from Book to Page nodes.

As you can see this is very direct approach to migrating some existing Drupal content around to other content types! It may not be the most flexible solution, but can meet many needs out the box.

Looking for quality web hosting? Look no further than Arvixe Web Hosting!

Tags: , , | Posted under Drupal | RSS 2.0

Author Spotlight

David Gurba

I am a web programmer currently employed at UCSB. I have been developing web applications professionally for 8+ years now. For the last 5 years I’ve been actively developing websites primarily in PHP using Drupal. I have experience using LAMP and developing data driven websites for clients in aviation, higher education and e-commerce. If you’d like to contact me I can be reached at david.gurba@arvixe.com

Leave a Reply

Your email address will not be published. Required fields are marked *