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!

sl786982

Great post full of useful tips! My site is fairly new and I am also having a hard time getting my readers to leave comments. Analytics shows they are coming to the site but I have a feeling “nobody wants to be first”. minecraft account

Immigration… [...]the time to

Immigration… [...]the time to read or visit the content or sites we have linked to below the[...]… Everydaylocksmith.org

devidmiller5060

Hey, great blog, but I don’t understand how to add your site in my rss reader. Can you Help me please? standard internazionali sicurezza alimentare arezzo

asidyah

Hi to everybody, here everyone is sharing such knowledge, so it’s fastidious to see this site, and I used to visit this blog daily. VisitMyWebsite

devidmiller5060

I was very pleased to find this site.I wanted to thank you for this great read!! I definitely enjoying every little bit of it and I have you bookmarked to check out new stuff you post. voyance-amour-eternel.com

shiprabrock

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. Formazione preposti grosseto

shiprabrock

Pretty good post. I just stumbled upon your blog and wanted to say that I have really enjoyed reading your blog posts. Any way I’ll be subscribing to your feed and I hope you post again soon. corso primo soccorso grosseto

You have raised an important

You have raised an important issue..Thanks for sharing..I would like to read more current affairs from this blog..keep posting.. anna university exam time table

A simple bookmarking tool

A simple bookmarking tool that makes it easy to save, organize and share your favorite web pages. Access your bookmarks from any computer, phone or tablet. Listango works on all modern web browsers… airtel payment bank charges

Declinging Gas Prices

This is my first time i visit here. I discovered such a significant number of fascinating stuff in your blog particularly its examination. Truly its incomprehensible article. Keep it up. Declinging Gas Prices

Pregnancy Without Surgical Abortion

Undergoing an Cara Menggugurkan Kandungan is a very personal and extremely big decision to take. To end a pregnancy before the fetus can live independently is abortion. The commonly used Obat Telat Bulan are Mifepristone and Methotrexate.

steve smith

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

shiprabrock

Great things you’ve always shared with us. Just keep writing this kind of posts.The time which was wasted in traveling for tuition now it can be used for studies.Thanks fashion trends

ohio drug rehab center

This is my first time i visit here. I discovered such a significant number of fascinating stuff in your blog particularly its examination. Truly its incomprehensible article. Keep it up. ohio drug rehab center

imranuddin

wow this good but ,I like your post and good pics may be any peoples not like because defrent mind all poeple , denim shirts Pakistan

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! aksi bela islam 112

devidmiller5060

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. VCP5

http://crazybulkreview.eubookshop.com/legal-steroids-d-bal-revie

D Bal is an alternate approach totally from the anabolic steroid treatment. Rather than an exceptionally focused, combined compound, it is a mix of a few regular fixings that the body can handle effortlessly and securely. It utilizes a few gentler methodologies for a similar impact, boosting the body's own muscle building forms reasonably. http://crazybulkreview.eubookshop.com/legal-steroids-d-bal-review/

shiprabrock

Easily, the article is actually the best topic on this registry related issue. I fit in with your conclusions and will eagerly look forward to your next updates. Just saying thanks will not just be sufficient, for the fantasti c lucidity in your writing. I will instantly grab your rss feed to stay informed of any updates. best memory foam mattress for the money

good script

thanks for the html code it look so great if i put it on my site gilangp

Couple Seeking Man

Our new male friend and my wife hit it off right away. It was a great evening and we parted without any pressure and found ourselves very interested. It was great to be able to talk to someone outside of a loud bar. We were able to discuss our interests and have had several dates afterwards.Couple Seeking Man

imranuddin

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. facebook

Cara Menggugurkan Kandungan - Tips Gugurkan Kandungan Yang Aman

Tips Menggugurkan Janin dengan selamat yang bisa dapat membantu anda dalam mengatasi masalah anda.Jika anda tidak ingin repot dan cepat secara ampuh dan herbal kami menyediakan Cara Mengatasi Datang Bulan secara tuntas dengan usia kandungan 1,2,3,4,5 bulan kami juga dapat membatu anda.

Bidan Obat Cytotec Menggugurkan Kandungan

Bagi Anda Yang memerlukan obat aborsi, kemungkinan Anda bisa mendapatkan obat aborsi dari bidan. Solusi Datang Bulan bisa juga Anda beli secara online melalui website Menggugurkan Kandungan yang menjual obat aborsi asli dan aman

iMessage alternative apps

iMessage alternative apps for Android lets you download the iMessage application on any Android device

home cleaning new york

Always so interesting to visit your site.What a great info, thank you for sharing. this will help me so much in my learning home cleaning new york/a>

sleep care capsule

design your own engagement ring

Unique designs are made to be cherished and what better way to pass on a family heirloom than to give it to one of your daughters.design your own engagement ring

shiprabrock

Great post full of useful tips! My site is fairly new and I am also having a hard time getting my readers to leave comments. Analytics shows they are coming to the site but I have a feeling “nobody wants to be first”. חאן במרכז

MAYO CLINIC CAR SERVICE MSP

Knowledge and experience of our staff enables us to deliver superb services which never compromise on quality. We are aimed to provide best services and continue to uphold client’s satisfaction. MAYO CLINIC CAR SERVICE MSP

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! Moto Metal truck wheels

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. rainbowpages

hafridi

Easily, the article is actually the best topic on this registry related issue. I fit in with your conclusions and will eagerly look forward to your next updates. Just saying thanks will not just be sufficient, for the fantasti c lucidity in your writing. I will instantly grab your rss feed to stay informed of any updates. ohsas 18001 arezzo

hafridi

I must say, I thought this was a pretty interesting read when it comes to this topic. Liked the material. . . . . standard internazionali brc ifs

cara alami mengobati asma

I am very pleased with the information that you submit, very interesting and helpful. However, if you want to know any other information, you can visit our page, one of them cara alami mengobati asma dengan jahe merah

devidmiller5060

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

devidmiller5060

I am glad you take pride in what you write. This makes you stand way out from many other writers that push poorly written content. Java and Android

devidmiller5060

I was very pleased to find this site.I wanted to thank you for this great read!! I definitely enjoying every little bit of it and I have you bookmarked to check out new stuff you post. voyance gratuite

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. rainbow-pages

devidmiller5060

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. rainbowpages

Diet Sehat

The best teacher is your last mistake Diet Sehat Alami Untuk Menurunkan Berat Badan.

Obat Menggugurkan Anak

Obat Cytotec tidak Menimbulkan rasa sakit atau efek samping, tidak bikin kepala pusing dan tidak ada efek negative. Karena Obat Menggugurkan Bayi yang kami jual telah dipakai oleh dokter dokter di negara maju. Yang mana aborsi di legalkan dan tidak menjadi soal, telah teruji secara klinis bisa Cara Gugurin Anak yang tidak di inginkan, misalnya karena kontrak kerja, belum siap berumah tangga, korban pemerkosaan atau akibat hubungan gelap.

shiprabrock

As a journalist, you know the importance of crafting an original article. Many press releases land on your desk or in your email, but rather than hastily copying and pasting sections from them, you can use the opportunity to craft engaging articles that are entirely your own. Here are 10 tips to ensure that what you write is original and not duplicated content. plagiarism detector

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. Niche wheels