Fix for hook_view and hook_insert

  1. /**
  2.   * Implementation of hook_view().
  3.   */
  4. function spot_forecast_view($node, $teaser = FALSE, $page = FALSE) {
  5.    $node = node_prepare($node, $teaser); // get it ready for display
  6. dpm("Dumping the values in spot_forecast_view" );
  7. dpm($node->forecastdate);
  8. $forecastdate = date("Y-m-d H:i",$node->forecastdate);
  9.    dpm($forecastdate);
  10.    $temperature = check_plain($node->temperature);
  11.    $rh = check_plain($node->rh);
  12.    $windspeed = check_plain($node->windspeed);
  13.    $winddirection = check_plain($node->winddirection);
  14.    $precip = check_plain($node->precip);
  15.    $location = check_plain($node->location);
  16.    $location_meta = check_plain($node->location_meta);
  17.    $code = check_plain($node->code);
  18.    $forecast_type = check_plain($node->forecast_type);
  19.    
  20.    
  21.    
  22.    // Add theme stuff here
  23.   // dpm( $servernid." ".$location." ".$stn_type." ".$forecasting." ".$elevation." ".$code);
  24.    $node->content['spot_forecast_info'] = array(
  25.       '#value' => theme('spot_forecast_info', $forecastdate,$temperature,$rh,$windspeed,$winddirection,$precip,$location,$location_meta,$code,$forecast_type),
  26.       '#weight' => 1,
  27.    );
  28.    
  29.    return $node;
  30. }
  31.  
  32.  
  33. /**
  34.   * implements hook_update().
  35.   */
  36. function spot_forecast_update($node) {
  37.  
  38.    if ($node->revision) {
  39.    spot_forecast_insert($node);
  40.    }
  41.    else {
  42.       if (!isset($node->location)) {
  43.       $node->location = '';
  44.       }
  45.  dpm("Dumping the values in spot_forecast_update" );    
  46. dpm($node);
  47. dpm($node->forecastdate);
  48. dpm(strtotime($node->forecastdate));
  49.  
  50. $wtf=db_query("UPDATE {spot_forecast} "
  51.           ."SET forecastdate = %d, temperature = %f, rh = %d, windspeed = %f,    winddirection = %d, location ='%s', location_meta = '%s' ,code = '%s',forecast_type='%s' "
  52.           ."WHERE vid = %d",
  53.         strtotime($node->forecastdate),
  54.         $node->temperature,
  55.       $node->rh,
  56.       $node->windspeed,
  57.       $node->winddirection,
  58.       $node->precip,
  59.       $node->location,
  60.       $node->location_meta,
  61.       $node->code,
  62.       $node->forecast_type,
  63.         $node->vid
  64.      );
  65. //var_dump($wtf);
  66.    //$node->forecastdate = strtotime($node->forecastdate);
  67.    //node_save($node);
  68.    }
  69.    
  70.  
  71. }

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.