I'd like to have an "add event on this date" link on the day view (possibly elsewhere) but I have no idea how to pass the date in the link to the date field in my event content type (I am using CCK). Is there a way to do this?

Cheers,
Chris

Comments

Danai-1’s picture

I agree. I'm using Drupal 5.3 with Calendar 5.x-1.7.
Each calendar entry has an entry, like d650ca85-48cd-4123-9587-ac7c6e562eda .

What I would suggest, is that this button automatically creates a node, and if the Path module is enabled, that it would also create the pathname http://www.website.ac/d650ca85-48cd-4123-9587-ac7c6e562eda .

Best regards

/Danai

karens’s picture

Version: 4.7.x-1.x-dev » 5.x-2.x-dev

The problem is that we don't know what to link to -- you might have several different date fields that were generated in different ways and they might be coming from different content types. So you need a way to indicate exactly what type of node to create from that link, since there isn't any way for the Calendar module to know what you want to do otherwise.

It could maybe be another setting in the calendar settings where you select the url to go to for that link.

This would take a patch to create a form element on the calendar settings where the user can set this url up, and add the link to the theme. If someone wants to create such a patch, it should be against the 5.2 version.

pelicani’s picture

There is a convenient theme function which you could use to display link for each day in the calendar.
Check out this function theme_calendar_date_box($date, $view, $params, $selected = FALSE)
Depending on the version of calendar, this function is constructed in different ways, but can achieve the same results.
For example...

  if ($view->calendar_type != 'day') {
    return '<div class="day">'. l($day, $url, NULL, $append) .'</div>'."\n";
  }

The above code displays the day for each view.
You can add an additional link (i.e. l('+', 'node/add/event/node/add/yourcontenttype/'.$year.'/'.$month.'/'.$day))
which will pass this day to the node add form for your content type.
Or get fancy and modify the link to display a popup of several options, i.e. insert different types of content for that day.

pelicani’s picture

That isn't all that is needed, you also need to alter the node/add form to use the date you are passing.

function custommodule_form_alter($form_id, &$form) {
if ($form_id == "event_node_form" && arg(1) == "add") {

If you are using the JS popup date, alter your form and modify this field ... $form['field_date'][0]['#default_value']['value']
There may be special form formatting for each type of date input.
In the past, I recall they were setup differently.
i.e. $form['field_date'][0]['value']['year']['#default_value']

scottrigby’s picture

This is a great feature :)

I'm also considering that it might be good to remove the link from the day, if there is no event (and just show the date grayed out).

I'm asking about it here because this is the only place I've seen so far where the day link function is discussed... is there an 'easy' way to make an if statement (if date contains an event, then show the link - if not, then not)?

Thanks for your advice!
:)
Scott

karens’s picture

Version: 5.x-2.x-dev » 6.x-2.x-dev

Moving D5 feature requests that aren't going to get into the initial official 5.2 release to be D6 feature requests that could potentially be backported to D5.2.

karens’s picture

Status: Active » Fixed

The latest code has a setting in the calendar page where you can identify the content type that should be linked to this calendar. If you fill that out you will get a '+' link at the top of the calendar to add a new event. It's at the top of every page, not in every date, but I think showing it on every date would create a lot of clutter.

Anonymous’s picture

hi karen,
just switched to the latest dev-code, but have no clue where this calender setting is supposed to appear.

would be are real usability boost!
thanx
bernd

edit: uups, sorry, found it in the views calendar page settings myself.
great work!

vito_a’s picture

I've tried it already at the http://drupal.org/node/145205#comment-1253868 ( the original post was http://drupal.org/node/22741#comment-1212444 ), seems that adding a '+' to every date, just below the day's number, doesn't makes much clutter, if there isn't many issues on that date however.

@KarenS: I was handling that with URLs like /node/add/event/2009/02/16 and some code at the 'date_all_day' module ( http://drupal.org/node/145205#comment-1253868 ). Would it be useful for someone, should I create a patch for it, or this is already in the latest release's code?

karens’s picture

It would be useful to have the date module check the URL for a date value and use it if there. But please start another issue for that to avoid confusion.

And I would provide the date in the ISO format, like YYYY-MM-DDTHH:MM:SS rather than splitting the date parts into different arguments. If the input is an ISO date, you can easily create a date object directly from that value to populate the form. So go ahead and work on a patch if you like. Thanks!

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.