Event calendar with popups

After building an event calendar (see this page), you might want a balloon / popup / tooltip to appear when hovering over a date. This tooltip would display the node titles of all events on that date. This is not very straightforward to implement in Drupal. I puzzled for 2 days to get this done.

I have written a module for this to make this process easier. You can find it at http://drupal.org/project/calendar_tooltips. It requires beautytips.

If you would like to know how it works or how to do it manually, read on.

There are many tooltip modules for Drupal out there. I use beautytips. Download it and install it. For Explorer you also need to download excanvas_r3, and unzip it in a new directory excanvas_r3 in the sites/all/modules/beautytips/other_libs directory.

The content of a tooltip (the text appearing on the balloon) can come from:

  1. an HTML element's attribute, by default the title attribute
  2. the content of an HTML element
  3. another (external) HTML document.

We won't be using the first method, because I had trouble including HTML markup in the title attribute of an HTML element. The third method, referring to another HTML document, is cumbersome to implement. I went for the second method. Say, for example, we have a date 25 (like in december 25). Normally the following HTML code is produced:

<div class="month mini-day-on"><a href="...">25</a></div>

The class "mini-day-on" is added when there are events on that date. If there are no events on that date, then the class "mini-day-off" is added.

What we are trying to achieve is placing the following HTML code after the hyperlink "25":

<span style="display:none">Christmas day</span>

The text "Christmas day" will not display on the calendar (because of the "display:none" style), but later on when we are done, it should display on the tooltip when you hover over "25" on the calendar. When there are multiple events on that date, it may be useful to list the events in an unordered list. This will look something like this:

<span style="display:none"><ul><li>Christmas day</li><li>Richie's birthday</li></ul></span>

In order to tell Beautytips where to get the content we need to override the calendar module's calendar-mini.tpl.php. Copy sites/all/modules/calendar/theme/calendar-mini.tpl.php to your theme's directory. Add the following code at the beginnning of the month-view div:

<?php
   $bt_options['mini-calendar'] = array(
      "area" => ".mini-day-on a",
      "contentSelector" => '$(this).next().html()'
   );
   beautytips_add_beautytips($bt_options);
?>

The area is a CSS selector that selects every hyperlink (eg. every date) on the mini calendar. The contentSelector is jQuery code which specifies the HTML code  of the hyperlink's first sibling (in our case the span element) as the tooltip's content.

Now we need to write some PHP code that produces the span element with the relevant event data. This is the difficult part. Look for the function called template_preprocess_calendar_datebox in sites/all/modules/calendar/theme/theme.inc. Copy this function to your theme's template.php. Replace the text "template" by the name of your theme. Insert the following code after this line:

$vars['class'] = 'mini-day-on';

Here is the code:

$bt_text = "<ul>";
foreach ($vars['items'][$date] as $time => $results_at_that_time)
   foreach ($results_at_that_time as $num => $result)
      $bt_text .= "<li>" . $result->raw->node_title . "</li>";
$bt_text .= "</ul>";
$bt_text = "<span style=\"display:none\">" . $bt_text . "</span>";
$vars['link'] = l($vars['day'], $vars['url']) . $bt_text;

What this does is aggregating all event data of that day and put it in an HTML unordered list, which is parented in a span element, which, on its turn, is placed next to the hyperlink.

That's it!

gratuite

Much thanks to you for another awesome article. Where else might anyone be able to get that sort of data in such an impeccable method for composing? I have a presentation one week from now, and I am on the search for such data.gratuite

apple iphone 7 plus lowest price in sri lanka

Apple Iphone 7 Plus Lowest Price in Sri Lanka | Apple Iphone 7 Plus Best Deal Price 2017: Dialcom.lk offers best deal to buy Apple Iphone 7 Plus at low price in Sri Lanka..apple iphone 7 plus lowest price in sri lanka

The Ideal Dream Laser Clinic

The Ideal Dream Laser Clinic is a cosmetic-medical center offering only certified, result-oriented hair removal, Skin rejuvenating, body countering and weight loss services for both men and women. Our team includes certified technicians, Registered Dietitian and specialized skin and laser consultants. We offer the highest level of safety and service in an environment where the main priority is your safety, health and privacy. Our clinic located in heart of north York , Yonge and Steeles area close to public transit. 5 min walk to center of Yonge and Steeles, 88 Steeles Ave. East Toronto. laser clinic toronto

free music download apps for android

Wonderful blog! I found it while surfing around on Yahoo News. Do you have any suggestions on how to get listed in Yahoo News? I’ve been trying for a while but I never seem to get there! Appreciate it..free music download apps for android

Alo Kanun

Extraordinary site! I truly worship how it is straightforward on my eyes it is. I am pondering how I might be exhorted at whatever point another post has been made..Alo Kanun

steve smith

Hi there, I found your blog via Google while searching for such kinda informative post and your post looks very interesting for me. buy youtube views

steve smith

Yes, great US Military force. Also, in his post you have given a chance to listen about US Military. I really appreciate your work. Thanks for sharing it. F1R wheels for sale

Visit Site

How about arranging the codes in Windows operating system? Visit Site

Decent post. I was checking

Decent post. I was checking continually this web journal and I am awed! To a great degree accommodating data exceptionally the last part I tend to such information a considerable measure. I was looking for this specific data for quite a while. Much obliged to you and good fortunes. should i refinance home

including reasonable comments

including reasonable comments here... focus exclusively on book covers

factors considered by whatsthebestbed reviews

You have done a great job. I will definitely dig it and personally recommend to my friends. I am confident they will be benefited from this site. factors considered by whatsthebestbed reviews

GOOD

Alat Pembesar Payudara MHCA

thanks

shahrukhkhan70

My friend mentioned to me your blog, so I thought I’d read it for myself. Very interesting insights, will be back for more! 4th of July deals that buyers want

Meja Makan Minimalis

pengencang payudara

shiprabrock

I would like to thank you for the efforts you have made in writing this article. I am hoping the same best work from you in the future as well. In fact your creative writing abilities has inspired me to start my own BlogEngine blog now. Really the blogging is spreading its wings rapidly. Your write up is a fine example of it. http://www.sleepjunkie.org/4th-of-july-sales-on-mattresses-from-sears-macys-more/

Its me Brayden Ben a

Its me Brayden Ben a professional and well experienced Designer.There are many designer more experienced then me , but now i am here to provide you the real design service I will design your name with real stones and give you high quality image , Unique and professional and no one will copy your design because its all Hand Made. awesome name design

Some Javascript features can

Some Javascript features can help you doing that. And CSS can help you for the design. kumpulan situs judi bola terpercaya

Iron Chandelier

I like modify my Java calendar appearance to be more colorful. Iron Chandelier

moldavite

The calendar pop up will help me so much to remind about what should I do today. moldavite

A debt of gratitude is in

A debt of gratitude is in order for offering this quality data to us. I truly delighted in perusing. Will clearly going to impart this URL to my companions. video submission

james jack

We are tied directly into the sate’s renewal database which allows us to process your request almost instantly. groove from home

bilalkhan3831

I would like to thank you for the efforts you have made in writing this article. I am hoping the same best work from you in the future as well. In fact your creative writing abilities has inspired me to start my own BlogEngine blog now. Really the blogging is spreading its wings rapidly. Your write up is a fine example of it. tibia videos

watch movies online 

wow, great, I was wondering how to cure acne naturally. and found your site by google, learned a lot, now i’m a bit clear. I’ve bookmark your site and also add rss. keep us updated. watch movies online

bilalkhan3831

My friend mentioned to me your blog, so I thought I’d read it for myself. Very interesting insights, will be back for more! evaluations of the most effective whatsthebestbed

payudara kendur

Best Michael Fiorie Review

This article is an engaging abundance of instructive information that is fascinating and elegantly composed. I recognize your diligent work on this and thank you for this data. You have what it takes to get consideration. Best Michael Fiorie Review

Cara Membesar Kan Payudara

Gimana Cara Memperbesar

shiprabrock

his is my first time i visit here. I found so many entertaining stuff in your blog, especially its discussion. From the tons of comments on your articles, I guess I am not the only one having all the leisure here! Keep up the excellent work. Twilx

Tips Sehat Alami

devidmiller5060

My friend mentioned to me your blog, so I thought I’d read it for myself. Very interesting insights, will be back for more! ESR sr02

台北當鋪

Can I change the setting with good appearance like 3D? 台北當鋪

good posts

indeed, most of the writing on this blog is less to my liking, but the writing I gave this comment is very memorable. Not a few also still interesting to observe. edutaining is a big part of this blog. thanks author. pressure washing vancouver

good posts

This is a great article thanks for sharing this informative information. I will visit your blog regularly for some latest post. I will visit your blog regularly for Some latest post.roof cleaning vancouver

good posts

This is a great article thanks for sharing this informative information. I will visit your blog regularly for some latest post. I will visit your blog regularly for Some latest post. voyance gratuite en ligne

good posts

A decent blog dependably concocts new and energizing data and keeping in mind that understanding I have feel that this blog is truly have each one of those quality that qualify a blog to be a one Motor Trade Insurance

AndreasLatvi

What should I do if I want to make a more interesting design for the calendar? http://www.krwlawyers.com/practice-areas-auto-accident-start.php

mayazoe

My friend mentioned to me your blog, so I thought I’d read it for myself. Very interesting insights, will be back for more! Verkehrswert von Immobilien ermitteln – Wer erstellt Wertgutachten für Immobilien? Tipps Immobiliensuche Dresden

bilalkhan3831

Great post! I am actually getting ready to across this information, is very helpful my friend. Also great blog here with all of the valuable information you have. Keep up the good work you are doing here. mattress-inquirer or other websites

james jack

Nice information, valuable and excellent design, as share good stuff with good ideas and concepts, lots of great information and inspiration, both of which I need, thanks to offer such a helpful information here. free movie sites

obatpenghilangkeloid