How to make multistep forms with drupal using various node types

1k views Asked by At

I'm creating a very basic classifieds website. In this website i'll have various content-types; such as :

  1. Car (which has the cck fields : year, kilometers, color
  2. House (which has the cck fields : number of floors, garden (yes/no)

So each 'element' is a content-type.

I'm listing all the content-types in a view that I display to the user aand then clicking on a link goes to 'create content type of type (clicked type)'.

It's working pretty well; but i can't get rid of the 'create new car' at the top of the create page (which reflects the 'drupalish' behaviour).

I'd like to have it in a more conveniant way such as a three step form like :

  1. Choose category
  2. Choose your options
  3. Register to post your new classified

I've seen the ctools; which provide 'almost' the multistep behaviour; however i can't imagine having all my dozen content-types being 'hardcoded' in a single module.

I wonder if anyone has achieved this kind of setup or if there's a kind of module that can do the trick. I'd like to keep a content type for each type of classified (the webmaster is now used to the interface).

Any help, starting points would be appreciated.

1

There are 1 answers

2
mirzu On BEST ANSWER

For the first step we had to solve a simular problem. To do so we created what was basicly an override of the /node/add page (the one that lists all the content types), which you've done. To change the title the simplest is to create a yourtheme_preprocess_page() function that changes the title when the url is /node/add or node/*/edit

However: I would strongly suggest switching to a system that uses 1 content type for all listings. We created a very simular site, and after working with different content types it because clear that having 1 content type with fields that were displayed conditionally was a much more sane solution. Using categories for the different product types, and then using the Conditional Fields module to hide and show the correct fields worked much better.

http://drupal.org/project/conditional_fields

Here is and example snippet for setting the title in a page preprocess function:

Setting the title on the node/add page:

  if (arg(0) == 'node' && arg(1) == 'add' && arg(2) == '') {
    $vars['title'] = 'Choose an Industry';
    $vars['head_title'] = $vars['title'] . " | " . variable_get('site_name', "Industry Trader");
  }