This tutorial was created using a fresh Drupal 6 install with Garland theme.
Add a [+] to each date on a month calendar, like the excellent [l:http://openatrium.com OpenAtrium] can do
First ensure /calendar is working and that you can add events
get and enable module https://drupal.org/project/prepopulate
Create a drupal6 module called addplus containing the following code
<?php
function addplus_preprocess_calendar_datebox(&$vars) {
global $user;
if (user_access('create event content', $user)) {
$options = array();
$options['query'] = array('edit[field_date][0][value]' => $vars['date']);
$options['attributes'] = array('title' => 'Add an event for THIS day');
$vars['add_event_link'] = l('+', 'node/add/event', $options);
}
}
function addplus_form_alter(&$form, $form_state, $form_id) {
if ($form_id == 'event_node_form' && arg(3) != '') {
$form['field_date']['#default_value']['value'] = arg(3) . ' 12:00:00';
$form['field_date']['#default_value']['value2'] = arg(3) . ' 13:00:00';
}
}
?>in modules/calendar/theme/calendar-datebox.tpl.php backup and then
add
<?php if ($add_event_link): ?>
<span class="add-event-link"><?php print $add_event_link; ?></span>
<?php endif; ?>Now you will see a [+] added to the left of each date. We will now style it so it only appears when we need it. open style.css and add
.add-event-link a:link, .add-event-link a:visited {
color: transparent;
text-decoration:none;
border:none;
}
.add-event-link a:hover {
color:#fff;
background:none repeat scroll 0 0 #4B85AC;
padding: 0.3em 0.5em 0.45em 0.5em;
text-align:center;
width:1.5em;
}
.calendar-empty {
display:none;
}Unfortunately ie seems to ignore 'transparent' so in your equivalent of fix-ie.css add
.add-event-link a:link, .add-event-link a:visited {
color: #fff;
}You now have a supercharged calendar!
If you would rather have the above work done for you it is available as a download via [l:theme/add-event-direct-each-date-month-calendar our shop]
A finished demo example can be seen at http://venturacottage.homedns.org/617startu02/calendar


Add new comment