Hi, I using the calendar block display and since I have only one event per day, I would like to link the days (only those which have events) on the mini calendar directly to their events.
I found an issue regarding the same idea but it's about an older version of the Project.
However, I found a function called template_preprocess_calendar_datebox where I got the basic idea but I was unable to put the node link into the vars['url'] variable.

Thanks,
matthew

Comments

Assigned:matthewdades» Unassigned

Any hint would be appreciated

Thanks

There isn't any setting within Views as far as I can tell. Instead, copy the calendar-datebox.tpl.php file into your theme and then you can change the link in there. Here's what it looks like after I was done with it:

<?php
// $Id: calendar-datebox.tpl.php,v 1.2.2.3 2010/11/21 14:15:32 karens Exp $
/**
* @file
* Template to display the date box in a calendar.
*
* - $view: The view.
* - $granularity: The type of calendar this box is in -- year, month, day, or week.
* - $mini: Whether or not this is a mini calendar.
* - $class: The class for this box -- mini-on, mini-off, or day.
* - $day:  The day of the month.
* - $date: The current date, in the form YYYY-MM-DD.
* - $link: A formatted link to the calendar day view for this day.
* - $url:  The url to the calendar day view for this day.
* - $selected: Whether or not this day has any items.
* - $items: An array of items for this day.
*/
if ($selected) {
   
$output = l($day, 'events/upcoming/' . $date);
} else {
   
$output = $day;
}
?>

<div class="<?php print $granularity ?> <?php print $class; ?>"> <?php print $output; ?> </div>

thanks for this piece of code, it's much appreciated !
any ideas on how to format this particular link to set it to the calendar page on the month of the events of that current day ?
something along the lines of :
$output = l($day, 'calendar/' . $date);
where $date is the year - month value.

Hi, thanks for the info.
I am also trying to link the mini calendar dates to their respective events instead of the day calendar.
Although I cant seem to link to the proper path, (how do I find it???)
as in $output = l($day,

'events/upcoming/'

. $date);
here is a link to the website
http://placide.charlem.com/
Thank you for any help.

If it is 1 event/day, u can set the url of the node same as the $output. It is a simple one, but it works.

Version:6.x-2.2» 7.x-3.x-dev

If someone wants to make mini calendar block display only one node and link it to a day than this is code you need:

<?php
/**
* @file
* Template to display the date box in a calendar.
*
* - $view: The view.
* - $granularity: The type of calendar this box is in -- year, month, day, or week.
* - $mini: Whether or not this is a mini calendar.
* - $class: The class for this box -- mini-on, mini-off, or day.
* - $day:  The day of the month.
* - $date: The current date, in the form YYYY-MM-DD.
* - $link: A formatted link to the calendar day view for this day.
* - $url:  The url to the calendar day view for this day.
* - $selected: Whether or not this day has any items.
* - $items: An array of items for this day.
*/
// If day has pictures
if(!empty($selected)) {
   
$entity = null;
   
// Find the first entity
       
$timeKey = array_keys($items[$date]);
       
$entity = $items[$date][$timeKey[0]][0];
   
// If we found the entity. We continue to redefine the link
   
if(!empty($entity)) {
       
// Make a link for the node
       
$nodeUrl = drupal_lookup_path("alias", "node/" . $entity->id);
       
$link = l($day, $nodeUrl);
       
// If we are on current node put class that will mark this node as current.
        // We do this because of future  css styling
       
$currentNodeUrl = drupal_lookup_path("alias", current_path());
        if(
$nodeUrl == $currentNodeUrl) {
           
$class = $class . " .current-selected-node" ;
        }
    }
   
// If there is no entity when we print only day number to visitor
   
else {
       
$link = $day;
    }
}
?>

<?php
print !empty($selected) ? $link : $day;
?>

I also want to link a day to it's event if one is available, here is my code for calendar-datebox.tpl.php file:

<?php
/**
* @file
* Template to display the date box in a calendar.
*
* - $view: The view.
* - $granularity: The type of calendar this box is in -- year, month, day, or week.
* - $mini: Whether or not this is a mini calendar.
* - $class: The class for this box -- mini-on, mini-off, or day.
* - $day:  The day of the month.
* - $date: The current date, in the form YYYY-MM-DD.
* - $link: A formatted link to the calendar day view for this day.
* - $url:  The url to the calendar day view for this day.
* - $selected: Whether or not this day has any items.
* - $items: An array of items for this day.
*/
?>

<?php
 
// If day has items.
 
if (!empty($selected)) {
   
$items = reset($items[$date]);
   
// Only get the first item.
   
$entity = $items[0];
   
$link = l($day, 'node/' . $entity->id, array('attributes' => array('title' => $entity->title)));
  }
?>

<div class="<?php print $granularity ?> <?php print $class; ?>"> <?php print !empty($selected) ? $link : $day; ?> </div>

Code in comment #8 seems to work well in Drupal 7, whereas the earlier code did not work on my install.

Thank you for good solution :-)

Thank you for the solution #8. It works well. I'm using Calendar 7.x-3.4. However, I would like to benefit from the colorbox version as provided when one clicks on an item's title in the Day display: this gives a popup window with arrows to look at other items occuring the same say. So it would be possible to handle the case of multiple events per day. Could anyone provide the code for this ?

It work fine. thank you very much,

#8 Workin' just fine! Thanks!

Issue summary:View changes

#8 works fine for me too. Also thanks.

re #11, it is easy enough to get the link to launch in colorbox using

$link = l($day, 'node/' . $entity->id, array('attributes' => array('rel' => array('colorbox-gallery'), 'class' => array('colorbox'),'title' => $entity->title)));
in place of
$link = l($day, 'node/' . $entity->id, array('attributes' => array('rel' => array('title' => $entity->title)));

But this reopens a new fully rendered page in the colorbox. What would be nice is to just render the node and have this open in a colorbox, which I don't know how to achieve.