I'm unsure if this had been discussed, I have not found it in the issue queue.

Like with many other calendar systems, often when you're viewing a calendar which you can edit, you should be able to generally click on one of the dates in that calendar to create a new event node with the corresponding date field prefilled to the date clicked. I am aware of the 'Add event' link that you can put at the top of the display, but in that case you still have to fill in the date manually.

Is this feature possible? Is it planned?

Thanks for your valuable time.

Comments

I've been searching for a solution to this for a long time now, anyone who knows how to get this function working?

I'm actually currently working on this very feature as a stand-alone module. What I've been working on is much more complex, but as part of my effort I spent a lot of time making the calendar plugin style more extensible.

If you use this patch:
http://drupal.org/node/1908018#comment-7035384

and then create a new module that implements hook_views_plugins (I used a module called "pattern"):

<?php
/**
* @file
*
* Creates pattern displays of Views results.
*/
/**
* Implementation of hook_views_plugins
*/
function pattern_views_plugins() {
 
$views_path = drupal_get_path('module', 'views');
 
$calendar_path = drupal_get_path('module', 'calendar');
 
$module_path = drupal_get_path('module', 'pattern');
 
$theme_path = $module_path;
 
module_load_include('inc', 'pattern', 'theme/theme');
 
// Limit these plugins to base tables that represent entities.
 
$base = array_keys(date_views_base_tables());
 
$data = array(
   
'module' => 'pattern', // This just tells our themes are elsewhere.
   
'style' => array(
     
'pattern_calendar_style' => array(
       
'title' => t('Calendar manager'),
       
'help' => t('Present view results as a manageable Calendar.'),
       
'handler' => 'pattern_plugin_style',
       
'path' => "$module_path/includes",
       
'theme' => 'calendar_style',
       
'theme file' => 'theme.inc',
       
'theme path' => "$calendar_path/theme",
       
'additional themes' => array(
         
'calendar_mini' => 'style',
         
'calendar_day' => 'style',
         
'calendar_week' => 'style',
         
'calendar_month' => 'style',
         
'calendar_year' => 'style',
         
'calendar_day_overlap' => 'style',
         
'calendar_week_overlap' => 'style',
        ),
       
'uses fields' => TRUE,
       
'uses grouping' => FALSE,
       
'uses row plugin' => TRUE,
       
'uses options' => TRUE,
       
'type' => 'normal',
       
'even empty' => TRUE,
       
'base' => $base,
      ),
    ),
  );
  return
$data;
}
?>

Then in a file called "includes/pattern_style_plugin.inc" you can use something like this code:

<?php
class pattern_plugin_style extends calendar_plugin_style {
  function
get_builder() {
   
$builder_type = 'pattern_builder_' . $this->options['calendar_type'];
    return new
$builder_type($this);
  }
}
class
pattern_builder_month extends calendar_builder_month {
  function
get_week_builder() {
    return new
pattern_builder_week($this->plugin);
  }
}
class
pattern_builder_week extends calendar_builder_week {
  function
get_day_builder($wday) {
    return new
pattern_builder_day_weekday($this, $wday);
  }
}
class
pattern_builder_day_weekday extends calendar_builder_day_weekday {
  function
calendar_build_day() {
   
parent::calendar_build_day();
   
$this->week->add_singleday_bucket($this->wday, "BUCKET!");
  }
}
?>

Notice in that last part, I'm injecting the text "BUCKET!" into the calendar at each day of a month. This will only work on a month view, I haven't get it set up for year/week/day yet.

There's a property of the "weekday" called $this->plugin. You can use $this->plugin->curday to get the current date and replace the text "BUCKET" with a link to add a date. You'll have to pass the date with a query string or a special arugment or something... still a lot to do between the code I've got and what you need but hopefully that's helpful

I'll post back anything I put up online regarding that stand-alone module I'm building.

Interesting code you got there! I didn't think that far (maybe as my php knowledge is little..). Will you submit your stand-alone module to the community? Otherwise, I just wait till you post it, before I get messing in php..

Ya i re-read that and it's pretty intense haha - I definitely plan on posting the stand-alone. I'm hoping to do so soon, but i should warn that its a bit complex

Is there a link yet? Chances are we could make use of it and contribute back based on use cases.

I will try to put up a sandbox today, but it might not be ready until early next week

in the mean time, you could create a simple module that uses hook_form_alter on your date-containing entity to look for a query string -- then the calendar td with a "single-day" class already has "data-date" attribute. You could use jQuery to write in a link to each td:

$(".single-day").each(function() {
  var date = $(this).data("date");
  var link = "<a href='/node/add/type?date=" + date + "'>Add</a>";
  $(this).append(link);
});

I don't like query strings :). I'm sure a path would do fine. Thanks!

ok here it is:
http://drupal.org/sandbox/tmsimont/1917664

please take a look and let me know. i'd love some help with this thing.

Cool, will do.

I also want the feature to click on calendar date to create events!!

Thank you!

Assigned:Unassigned» tictac42
Category:feature» support

I am currently in dev, and trying to click events on my calendar to view nodes that I have already established (logged in as Admin). Is there a way to toggle between clicking the calendar to add events, and clicking the titles to view the nodes, I imagine somewhere in configuration? I am pretty new to Drupal...
thanks!

+1

+1