Hi all

I have a function EFQ showing a selection of events based on the current week, works ok. The problem is, Today/Sunday events never seem to show for any given week, can't figure out what I'm doing wrong.

Example: I have events for today, though the script defaults to 'no events for this week'.

function gigsthisweek_block_global($setrange, $setdate) {
  
  // Snippet for showing events for current week
  $dow = date('N');
  
  if ( $dow == 7 ) { // Sunday
    $offset = 'today';
  } else {
    $offset = 'sunday';
  }
  
  $query = new EntityFieldQuery();
  $query
      ->entityCondition('entity_type', 'events')
      ->entityCondition('bundle', 'event')
      ->fieldCondition('field_event_date', 'value', date("Y-m-d"), '>') // end date after today
      ->fieldCondition('field_event_date', 'value', date("Y-m-d",strtotime($offset)), '<')
      ->fieldOrderBy('field_event_date', 'value', 'ASC')
      ->range(0, $setrange);  

I did try >= though not sure if this is allowed within a fieldcondition, nothing changed:

->fieldCondition('field_event_date', 'value', date("Y-m-d"), '>=') // end date after today 

Can anybody advise what I'm doing wrong or how I can fix this?

Thanks, Barry

Comments

computerbarry’s picture

->fieldCondition('field_event_date', 'value', date("Y-m-d"), '>') // end date after today
->fieldCondition('field_event_date', 'value', date("Y-m-d",strtotime($offset)), '<')

If I change < to > in the second condition, the events are listed from next week starting with Sunday, instead of Monday. We need to tweak something so we make up the lost/missing day.

Barry

The more you learn.... the more you learn there is more to learn.

computerbarry’s picture

Can anybody help with this?

Cheers, Barry

The more you learn.... the more you learn there is more to learn.