Maybe I am missing something but it would be helpful if there was an optional drop box that listed a year's worth of months in either direction of the currently displayed month so that a user can jump to that month instead of stepping month by month.

CommentFileSizeAuthor
#6 date_jumper5.diff5.3 KBgeodaniel
#5 date_jumper.diff4.39 KBgeodaniel

Comments

asanvicente’s picture

Any luck with this? I've been trying to figure it out with no luck.

spamjim’s picture

Title: Ability to jump forward or back to specific dates » Offer the ability to jump forward or back more than one month at a time
Version: 5.x-2.x-dev » 4.7.x-1.x-dev
Assigned: geodaniel » Unassigned
Status: Needs review » Active

Here is what I started working on but got distracted so it is not finished. I placed and called this function in event.theme. It should probably go somewhere else but I have not had time to return to it and think it through fully.

This presents a droplist of the next 12 months. On change, it jumps to the new month page view.

//MONTH JUMP SELECTOR - START
//2006-11-07
function jumpmonth()
{
print ("<form name=\"calendarjump\">\n");
print ("<select name=\"calendarselector\" OnChange=\"location.href=calendarjump.calendarselector.options[selectedIndex].value\">\n");
print ("<option selected>Choose a month...</option>\n");
$monthcount=0;
while($monthcount<=12)
	{
	$futuretime = strtotime("+$monthcount month");
	$monthjumplink = 'event/' . date("Y/m/d", $futuretime) . '/month/all/all';
	print ("<option value=\"$monthjumplink\">" . date("F Y", $futuretime) . "</option> \n");
	$monthcount++;
	}
print ("</select></form>");	
}
//MONTH JUMP SELECTOR - END

Any suggestions for improvement are appreciated.

asanvicente’s picture

I'll give this a try. Thanks.

geodaniel’s picture

It would be nice to be able to keep in place any filters that have already been set as well

geodaniel’s picture

Title: Offer the ability to jump forward or back more than one month at a time » Ability to jump forward or back to specific dates
Assigned: Unassigned » geodaniel
Status: Active » Needs review
StatusFileSize
new4.39 KB

I've spent a bit of time on this today and attach a patch that gives admins the option to include a jump-to-date control on calendar pages. The control has a dropdown select menu for days, months and years (only years that have events in are included) and a button to jump to that date. Any filters that are already applied should be remembered.

I didn't want to do the autosubmit because it would mean doing it for each dropdown and would force someone to refresh the page three times when trying to enter a date.

geodaniel’s picture

Version: 4.7.x-1.x-dev » 5.x-2.x-dev
StatusFileSize
new5.3 KB

Here's a patch for Drupal 5 too. I can't get any of the filters at the top of the calendar to actually work in the Drupal 5 version though, which could be a separate issue (the drupal_goto commands do not appear to be being called).

geodaniel’s picture

It looks like this is related to a change in the way the forms are structured (no longer $_POST['edit']['event_type_select'], for example, but $_POST['event_type_select']). Changing these values helps it work a little better, though seemingly intermittently. I've read somewhere that $_POST use should be dropped in favour of $form_values but that variable doesn't seem to yield any values.

mennonot’s picture

+1 on this patch. Thanks for your work on this, geodaniel.

I used it to patch Event 5.x and found it very useful. Two minor corrections:

First, as geodaniel suggested in his January 22 comment, the post section should be changed to the following to remove the [edit] element:

  if ($_POST['event_day_select'] || $_POST['event_month_select'] || $_POST['event_year_select']) {
    drupal_goto('event/'. $_POST['event_year_select'] .'/'. $_POST['event_month_select'] .'/'. $_POST['event_day_select'] .'/'. $view .'/'. ($types ? $types : 'all') .'/'. ($tids ? $tids : 'all'));
  }

Secondly, when defining the default selection for the month select box, the patch needs to strip the leading zero off of the $curmonth variable so that it matches up with the correct month in the array. Here's how I corrected the code with ltrim():

function event_date_jump_form($curday, $curmonth, $curyear) {
  $days = drupal_map_assoc(range(1,31));
  $months = array(1 => t('January'), t('February'), t('March'), t('April'), t('May'), t('June'), t('July'), t('August'), t('September'), t('October'), t('November'), t('December'));
  $year_min = gmdate('Y', variable_get('event_range_prev', 0));
  $year_max = gmdate('Y', variable_get('event_range_next', 0));
  $years = drupal_map_assoc(range($year_min, $year_max));
  $curmonth = ltrim($curmonth, 0);

  $form['event_day_select'] = array(
    '#prefix' => '<div class="container-inline">',
    '#type' => 'select',
    '#default_value' => $curday,
    '#options' => $days);
  $form['event_month_select'] = array(
    '#type' => 'select',
    '#default_value' => $curmonth,
    '#options' => $months);

Status: Active » Needs review
japerry’s picture

Status: Needs review » Closed (outdated)

Event for Drupal 8 is unrelated to older versions. If an issue similar to this one exists, please open a new issue with the 8.x branch.