1

I am looking around a way to get the date pager next/prev/current value inside the current view.I am listing events in a month and have used date pager.Display is of month type so in header it shows the month value.and in the next and prev it shows the next month. I need to know the value for the pager navigation. Thanks in advance. Arpit

2

I found a work around, keeping in mind that the pager works for calendar view by changing date in the URL.

I created a custom form with fields as day, month, year whose field type is select (dropdown).

This is the code for the form and the submission handler.

function mymodule_get_event_view_date_filter($form, &$form_state) {
  $form = array();
  $year = date('Y');
  $year_options = array(
    $year - 4 => t($year - 4),
    $year - 3 => t($year - 3),
    $year - 2 => t($year - 2),
    $year - 1 => t($year - 1),
    $year => t($year),
    $year + 1 => t($year + 1),
    $year + 2 => t($year + 2),
    $year + 3 => t($year + 3),
    $year + 4 => t($year + 4),
  );
  $month = date('m');
  $month_options = array(
    '1' => 'Jan',
    '2' => 'Feb',
    '3' => 'March',
    '4' => 'April',
    '5' => 'May',
    '6' => 'June',
    '7' => 'July',
    '8' => 'Aug',
    '9' => 'Sep',
    '10' => 'Oct',
    '11' => 'Nov',
    '12' => 'Dec',
  );
  $form['event-date-container'] = array(
    '#type' => 'container',
    '#prefix' => '<div id="event-date-container">',
    '#suffix' => '</div>',
  );
  $form['event-date-container']['year'] = array(
    '#type' => 'select',
    '#options' => $year_options,
    '#prefix' => '<div id="event-year">',
    '#default_value' => isset($_SESSION['event']['year']) ? $_SESSION['event']['year'] : $year,
    '#suffix' => '</div>',
  );
  $form['event-date-container']['month'] = array(
    '#type' => 'select',
    '#options' => $month_options,
    '#prefix' => '<div id="event-month">',
    '#default_value' => isset($_SESSION['event']['month']) ? $_SESSION['event']['month'] : $month,
    '#suffix' => '</div>',
  );
  $form['event-date-container']['submit_form'] = array(
    '#type' => 'submit',
    '#value' => t('Apply'),
    '#submit' => array('_mymodule_event_view_date_submit'),
  );
  unset($_SESSION['event']);
  return $form;
}

function _mymodule_event_view_date_submit($form, $form_state) {
  global $base_url;
  $_SESSION['event']['year'] = $form_state['values']['year'];
  $_SESSION['event']['month'] = $form_state['values']['month'];
  drupal_goto('calendar-node-field-event-date/month/' . $form_state['values']['year'] . '-' . $form_state['values']['month']);
}

Now call this form in your calendar view in view header print.

drupal_render(drupal_get_form(mymodule_get_event_view_date_filter));
0

I tried the above solution and could not get it working. After investigating, I managed to get it working by putting echo in the call in the header php:

<?php echo drupal_render(drupal_get_form('mymodule_get_event_view_date_filter')); ?>

Like this:

Screenshot of header php call

This site is temporarily in read only mode and not accepting new answers.

Not the answer you're looking for? Browse other questions tagged .