Drupal – Customize the day link inside the Mini Calendar Navigation Block

Previous related posts:

 

By default the day links inside the mini calendar block will redirect you to the calendar day view of that day.

 

Sometimes we would like that link to be another view display such as a view which list all the events of a specific day. In that case, we have to customize the calendar datebox template file which is located @ theme/calendar-datebox.tpl.php inside the calendar module folder. Copy this file to your theme folder and edit it as follow.

<?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.
 */
?>
<!--div class="<?php print $granularity ?> <?php print $class; ?>"> <?php print $selected ? $link : $day; ?> </div-->
<?php
  if ($selected) {
    $output = l($day, 'events/' . $date);
  } else {
    $output = $day;
  }
?>
<div class="<?php print $granularity ?> <?php print $class; ?>"> <?php print $output; ?> </div>

 

Clear cache and reload the page and you will see the link is now pointing to the events url.

 

Done =)

Reference:

Advertisements

8 thoughts on “Drupal – Customize the day link inside the Mini Calendar Navigation Block”

    1. Then you need to customize the the following highlighted line.

      <?php
        ...
        if ($selected) {
          $output = l($day, 'events/' . $date);
        } else {
          $output = $day;
        }
        ...
      ?>
      

      But i am not sure how you could get the node ID in the .tpl.php.

      Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s