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.

Eric.London's picture

I created a CCK node that contained a field used to store information not very user friendly. I wanted the data to show up correctly on a calendar view, so I added some code to my theme to override the display functionality of the node. I put the following function in my template.php file:

<?php
function MYTHEME_calendar_calendar_node($node, $type) {
 
$fieldName = 'node_data_field_MYFIELDNAME_field_MYFIELDNAME_value';
  if (
strlen($node->fields[$fieldName])) {
   
$node->fields[$fieldName] = 'MYNEWHTML';
  }
  return
theme_calendar_calendar_node($node, $type);
}
?>

Here's how you can use a few third party moves to implement a calendar date picker. Install and enable the following modules... CCK, date (http://drupal.org/project/date), and Javascript Tools (http://drupal.org/project/jstools). In Javascript Tools, you want to enable jscalendar. First, create a new CCK node type (or edit an existing node type). Then, click on add field, and choose date: Text Field with javascript pop-up calendar. When editing or adding the node, you get a calendar icon next to your text input field. When clicking on it, you'll get an interactive calendar...

Syndicate content