Load another node after CTools modal window is submited

Continuing from http://drupaldump.com/ctools-modal-window-return-message-same-modal-win… we can also do some more stuff after one modal is submited, we can load another content in it. For example a whole node, we just need to load it and then render it properly. Problem you can encounter is that you will need to change the modal size

 
if ( $form_state['submitted']){

    $output = array();
    $node = node_load(7);

  // Content for modal window:
  $contents = render(node_view($node, 'full', NULL));
  $output[] = ctools_modal_command_display($node->title, $contents);
    print ajax_render($output);
    exit;
}

also for some cool examples of modal windows, check this repository
https://github.com/jlbellido/ctools_expamples

Inspired by the examples above we can also create a node add form after submiting of the first modal window.

f ( $form_state['submitted']){

  module_load_include('inc', 'node', 'node.pages');

  $node = (object) array(
        'uid' => $user->uid,
        'name' => (isset($user->name) ? $user->name : ''),
        'type' => 'team',
        'language' => $language->language,
  );
  $node->title = NULL;

  node_object_prepare($node);

  $form_state = array(
    'ajax' => TRUE,
    'title' => 'Add a new article',
    'node' => $node,
  );

  $commands = ctools_modal_form_wrapper('team_node_form', $form_state);

  if (!empty($form_state['executed'])) {
    ctools_add_js('ajax-responder');
    $commands[] = ctools_modal_command_display(t('Node Saved'), theme_status_messages(array('display' => 'status')));
  }

  print ajax_render($commands);
    exit;
}