I am only using the calendar module to be displayed as a block, not a page...and it's connected to my blog.

I realize most people want the calendar for projects potentially listing several events per day, but I will always only post one event per day. Is there a way to delete the interim page listing all events for that day, and just link directly to the blog article?

However, I would like to keep that feature for the "Month" link in the calender...IE: when visitor clicks on July they will see a list of all articles for July.

Thanks in advance.
paul

Comments

KarenS’s picture

Status: Active » Fixed

There is a theme in calendar.theme called 'calendar_date_box'. That is where the link to the day is created. Just create your own version of that function and put it in your theme folder, and make the link go wherever you want it to.

finedesign’s picture

Version: 5.x-1.4 » 5.x-1.5
Component: User interface » Code

Thanks Karen-

First, I haven't responded in awhile because I thought the Drupal site would email with responses to my post.

I'm sorry to say I really don't understand the function you describe. I've copied it over to my template.php file and tried some things, but I really don't know what I'm doing. Any chance you could elaborate?

Just to make things clearer, the function follows:

function mythemename_calendar_date_box($year, $month, $day, $view, $mini = FALSE, $selected = FALSE, $url, $append = '') {

  $url = $url ? $url .'/'. $year .'/'. $month .'/'. $day : 'calendar/'. $year .'/'. $month .'/'. $day;
  if ($mini) {
    if ($selected) {
      return '<div class="mini-day-on">'. l($day, $url, NULL, $append) .'</div>';
    }
    else {
      return '<div class="mini-day-off">'. l($day, $url, NULL, $append) .'</div>';
    }
  }
  switch ($view) {
    case 'table':
        $output = '<div class="day">'. l(t('!month / !day', array('!month' => $month, '!day' => $day)), $url, NULL, $append) .'</div>'."\n";
      break;
    case 'list':
        $output = '<div class="day">'. l(date_format_date('l, F j, Y', date_mktime(array('mon' => $month, 'mday' => $day, 'year' => $year))), $url, NULL, $append) .'</div>'."\n";
      break;
    case 'day':
     break;
    default:
        $output = '<div class="day">'. l($day, $url, NULL, $append) .'</div>'."\n";
      break;
  }
  return $output;
}
KarenS’s picture

Now that I look at this closer, I see the problem. The way to link to the blog is to to change $url at the top of the function to something like:

$url = 'node/'. $node->nid;

But you don't have any $nodes at the point where the date box is created (on the month view), you'll only have your list of $nodes when you actually go to the day view, so there is no way to do this. Based on the way Views and the Views calendar work, I'm not sure there's any easy way to do what you want. And this is not a common use case, so it wouldn't be worth spending a lot of time trying to figure out a work-around.

Sorry!

KarenS’s picture

Actually there is a way to do it, but it's only for someone who is willing to dig into Views and who knows a bit of PHP. I can just point you in the right direction if you want to try it. You would have to run something like the following:

$view = $GLOBALS['current_view'];
$results = views_build_view('items', $view, array($year, $month, $day));
$node = $results['items'][0];
$url = 'node/'. $node->nid;

That is just a general idea of the way you would have to do it. The idea is to run the view that would have been run on the day view by building the view with the arguments for that day, but ask for the array of items it would have found instead of the full view. Then pop off the first item as your node and link to it.

I can't help you debug this and get it working, I'm just providing this to point you in the direction of a solution.

finedesign’s picture

Thank you Karen. This helps a lot actually. I'll see what I can find out.

Anonymous’s picture

Status: Fixed » Closed (fixed)
Eugene Fidelin’s picture

I also use this theme function to turn off link to those dates which have not any nodes

funkeyrandy’s picture

can anyone post the full code to this...maybe returning a day list like this:

jan30 2008
-node
-node
jan29 2008
-node
-node

etc

thanks!