The block should be visible only for this specific content type (event) and if the cost is not $0 and the (current date - event date > 48 hours). Using the below php snippet, any ideas?

Content Type=event
CCK Cost Field=cckfield_event_costs
CCK Date Field=cckfield_event_date

$return = FALSE;   
if ( (arg(0) == 'node') && is_numeric(arg(1)) )  {  
  $nid = arg(1);  
  $node = node_load($nid);  
  $type = $node->type;
  $cost = $node->cckfield_event_costs;
  $eventdate = $node->cckfield_event_date;  
  if ( ($type == "event") && ($cost != "$0 - Free")) {  
     $return = TRUE;  
  }  
}  
  
return $return;  

Comments

timlie’s picture

You should use:

$node->cckfield_event_costs[0];

ypay’s picture

Thank you for your suggestion. However it outputs "Array" and not "$0 - Free". Also any pointers on the date comparison? Appreciate it...

GreyHawk’s picture

Perhaps you need to specify the value you're assigning to the $cost variable...I think this may get you closer:

$cost = $node->cckfield_event_costs[0]['value'];

ypay’s picture

Using the dateDiff function this works...hope it helps someone with a similar need can modify the below to suit their particular needs.

$return = FALSE;
if ( (arg(0) == 'node') && is_numeric(arg(1)) )  { 
  $nid = arg(1);  
  $node = node_load($nid);  
  $type = $node->type;
  $cost = $node->cckfield_event_costs[0]['value'];
  $now = date('m/d/Y');
  $eventdate = date('m/d/Y', strtotime($node->cckfield_event_date[0]['value']));
  $DayDiff = dateDiff("/", $now, $eventdate);
  if ( ($type == "event") && ($cost != "$0 - Free") && ($DayDiff > "2") ) {  
     $return = TRUE;  }  
}  
return $return; 
GreyHawk’s picture

Thanks for the code snippet. It may come in handy.

namjitharavind’s picture

could you please tell me where i will put thiscode snippet?
Thanks?