background image
HomeRecent PostsDrupalSearchTagsRSSContactAboutAccount
Eric.London's picture

When viewing my calendar in year view, there are not previous and next links in the calendar navigation.

It possible that my calendar is not configured properly, but here's how I modified the calendar theming to insert the links. First, I copied the calendar-main.tpl.php file into my theme directory. Then I added a conditional statement to check if it's the year view and inserted some PHP:

<?php
// $Id: calendar-main.tpl.php,v 1.2.2.3 2008/10/21 14:20:33 karens Exp $
/**
* @file
* Template to display calendar navigation and links.
*
* @see template_preprocess_calendar_main.
*
* $view: The view.
* $calendar_links: Array of formatted links to other calendar displays - year, month, week, day.
* $calendar_popup: The popup calendar date selector.
* $display_type: year, month, day, or week.
* $mini: Whether this is a mini view.
* $min_date_formatted: The minimum date for this calendar in the format YYYY-MM-DD HH:MM:SS.
* $max_date_formatted: The maximum date for this calendar in the format YYYY-MM-DD HH:MM:SS.
*
*/
//dsm('Display: '. $display_type .': '. $min_date_formatted .' to '. $max_date_formatted);
?>


<div class="calendar-calendar">
  <?php if (!empty($calendar_popup)) print $calendar_popup;?>
  <?php if (empty($block)) print theme('links', $calendar_links);?>
   
  <?php
 
if ($display_type == 'year') {
       
   
// generate the html for the calendar navigation
   
$nav = theme('date_navigation', $view);
       
   
// define html containers to insert links into
   
$prev = '<div class="date-prev">';
   
$next = '<div class="date-next">';
       
   
// create link for previous/next year
   
$prevLink = l('<< prev', 'calendar/' . (arg(1)-1));
   
$nextLink = l('next >>', 'calendar/' . (arg(1)+1));
       
   
// find position of end of previous div container
   
$prevPos = stripos($nav,$prev) + strlen($prev);
       
   
// insert previous link
   
$nav = substr($nav, 0, $prevPos) . $prevLink . substr($nav, $prevPos);
       
   
// find position of end of next div container
   
$nextPos = stripos($nav,$next) + strlen($next);
       
   
// insert next link
   
$nav = substr($nav, 0, $nextPos) . $nextLink . substr($nav, $nextPos);
       
    print
$nav;
       
  } else {
    print
theme('date_navigation', $view);
  }
 
?>


</div>
?>

Now, my calendar has previous and next navigation links.

Syndicate content