DrupalBin
Submit Code
About
Recent Posts
Code
Fix for Fix for Code
Fix for Code
Code
Node type whitelist
an axe coach accessories
coach purses married
Fix for de las ghd alturas
de las ghd alturas
Code
more
User login
Log in using OpenID:
What is OpenID?
Username:
*
Password:
*
Log in using OpenID
Cancel OpenID login
Create new account
Request new password
Tags
CCK
drupal
fapi
jquery
menu
module
php
simpletest
taxonomy
test
theme
views
more tags
Home
Fix for hook_view and hook_insert
View
Fix
March 12, 2010 - 1:50pm — Anonymous
/**
* Implementation of hook_view().
*/
function
spot_forecast_view
(
$node
,
$teaser
=
FALSE
,
$page
=
FALSE
)
{
$node
=
node_prepare
(
$node
,
$teaser
)
;
// get it ready for display
dpm
(
"Dumping the values in spot_forecast_view"
)
;
dpm
(
$node
-
>
forecastdate
)
;
$forecastdate
=
date
(
"Y-m-d H:i"
,
$node
-
>
forecastdate
)
;
dpm
(
$forecastdate
)
;
$temperature
=
check_plain
(
$node
-
>
temperature
)
;
$rh
=
check_plain
(
$node
-
>
rh
)
;
$windspeed
=
check_plain
(
$node
-
>
windspeed
)
;
$winddirection
=
check_plain
(
$node
-
>
winddirection
)
;
$precip
=
check_plain
(
$node
-
>
precip
)
;
$location
=
check_plain
(
$node
-
>
location
)
;
$location_meta
=
check_plain
(
$node
-
>
location_meta
)
;
$code
=
check_plain
(
$node
-
>
code
)
;
$forecast_type
=
check_plain
(
$node
-
>
forecast_type
)
;
// Add theme stuff here
// dpm( $servernid." ".$location." ".$stn_type." ".$forecasting." ".$elevation." ".$code);
$node
-
>
content
[
'spot_forecast_info'
]
=
array
(
'#value'
=
>
theme
(
'spot_forecast_info'
,
$forecastdate
,
$temperature
,
$rh
,
$windspeed
,
$winddirection
,
$precip
,
$location
,
$location_meta
,
$code
,
$forecast_type
)
,
'#weight'
=
>
1,
)
;
return
$node
;
}
/**
* implements hook_update().
*/
function
spot_forecast_update
(
$node
)
{
if
(
$node
-
>
revision
)
{
spot_forecast_insert
(
$node
)
;
}
else
{
if
(
!
isset
(
$node
-
>
location
)
)
{
$node
-
>
location
=
''
;
}
dpm
(
"Dumping the values in spot_forecast_update"
)
;
dpm
(
$node
)
;
dpm
(
$node
-
>
forecastdate
)
;
dpm
(
strtotime
(
$node
-
>
forecastdate
)
)
;
$wtf
=
db_query
(
"UPDATE {spot_forecast} "
.
"SET forecastdate = %d, temperature = %f, rh = %d, windspeed = %f, winddirection = %d, location ='%s', location_meta = '%s' ,code = '%s',forecast_type='%s' "
.
"WHERE vid = %d"
,
strtotime
(
$node
-
>
forecastdate
)
,
$node
-
>
temperature
,
$node
-
>
rh
,
$node
-
>
windspeed
,
$node
-
>
winddirection
,
$node
-
>
precip
,
$node
-
>
location
,
$node
-
>
location_meta
,
$node
-
>
code
,
$node
-
>
forecast_type
,
$node
-
>
vid
)
;
//var_dump($wtf);
//$node->forecastdate = strtotime($node->forecastdate);
//node_save($node);
}
}
Submit Fix
Summary:
Tags:
Any tags you'd like to associate with your code, delimitered by commas (example: Views, CCK, Module, etc).
Show summary in full view
/** * Implementation of hook_view(). */ function spot_forecast_view($node, $teaser = FALSE, $page = FALSE) { $node = node_prepare($node, $teaser); // get it ready for display dpm("Dumping the values in spot_forecast_view" ); dpm($node->forecastdate); $forecastdate = date("Y-m-d H:i",$node->forecastdate); dpm($forecastdate); $temperature = check_plain($node->temperature); $rh = check_plain($node->rh); $windspeed = check_plain($node->windspeed); $winddirection = check_plain($node->winddirection); $precip = check_plain($node->precip); $location = check_plain($node->location); $location_meta = check_plain($node->location_meta); $code = check_plain($node->code); $forecast_type = check_plain($node->forecast_type); // Add theme stuff here // dpm( $servernid." ".$location." ".$stn_type." ".$forecasting." ".$elevation." ".$code); $node->content['spot_forecast_info'] = array( '#value' => theme('spot_forecast_info', $forecastdate,$temperature,$rh,$windspeed,$winddirection,$precip,$location,$location_meta,$code,$forecast_type), '#weight' => 1, ); return $node; } /** * implements hook_update(). */ function spot_forecast_update($node) { if ($node->revision) { spot_forecast_insert($node); } else { if (!isset($node->location)) { $node->location = ''; } dpm("Dumping the values in spot_forecast_update" ); dpm($node); dpm($node->forecastdate); dpm(strtotime($node->forecastdate)); $wtf=db_query("UPDATE {spot_forecast} " ."SET forecastdate = %d, temperature = %f, rh = %d, windspeed = %f, winddirection = %d, location ='%s', location_meta = '%s' ,code = '%s',forecast_type='%s' " ."WHERE vid = %d", strtotime($node->forecastdate), $node->temperature, $node->rh, $node->windspeed, $node->winddirection, $node->precip, $node->location, $node->location_meta, $node->code, $node->forecast_type, $node->vid ); //var_dump($wtf); //$node->forecastdate = strtotime($node->forecastdate); //node_save($node); } }
Syntax highlighting mode:
ActionScript
ColdFusion
Diff
Drupal 5
Drupal 6
HTML
INI
Javascript
MySQL
PHP
Python
robots.txt
SQL
Text
Select the syntax highlighting mode to use.
See Also:
Order
Title:
URL:
-1
0
1
Title:
URL:
-1
0
1
Any links you'd like to have associated with the post (Drupal.org issue, Wikipedia article, etc).
File attachments
Changes made to the attachments are not permanent until you save this post. The first "listed" file will be included in RSS feeds.
Attach new file:
The maximum upload size is
1 MB
. Only files with the following extensions may be uploaded:
jpg jpeg gif png txt doc xls pdf ppt pps odt ods odp phps
.