Fix for Module to overrule the save settings of the "new node" form

  1. <?php
  2. /**
  3. * Display help and module information
  4. * @param path which path of the site we're displaying help
  5. * @param arg array that holds the current path as would be returned from arg() function
  6. * @return help text for the path
  7. */
  8. function node_noredirect_help($path, $arg) {
  9.   $output = '';  //declare your output variable
  10.   switch ($path) {
  11.     case "admin/help#node_noredirect":
  12.       $output = '<p>'.  t("This module prevents the save button to redirect to the overview, but stays at the edit page") .'</p>';
  13.       break;
  14.   }
  15.   return $output;
  16. } // function onthisdate_help
  17.  
  18. function node_noredirect_form_alter(&$form, $form_state, $form_id) {
  19.         if (isset($form['type']) && isset($form['#node']) && $form['type']['#value'] .'_node_form' == $form_id) {
  20.                 echo '<pre>'.print_r($form_state, true).'</pre>';
  21.                 unset($form_state['redirect']);
  22.  
  23.                 if($_SERVER['REQUEST_METHOD'] == 'POST') {
  24.                         $select_latest_nid = 'SELECT MAX(nid) AS highest_nid FROM {node}';
  25.                         $result_latest_nid = db_query($select_latest_nid);
  26.                         $latest_nid = db_result($result_latest_nid);
  27.  
  28.                         //header('Location: /node/'.$latest_nid.'/edit');
  29.                         echo '<script type="text/javascript">window.location.href = "/node/'.$latest_nid.'/edit";</script>';
  30.                 }
  31.         }
  32. }

Submit Fix

Any tags you'd like to associate with your code, delimitered by commas (example: Views, CCK, Module, etc).
Select the syntax highlighting mode to use.