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!

activate your phone online

I really enjoy simply reading all of your weblogs. Simply wanted to inform you that you have people like me who appreciate your work. Definitely a great post. Hats off to you! The information that you have provided is very helpful. activate your phone online

corflute signs

Nice to be visiting your blog again, it has been months for me. Well this article that i’ve been waited for so long. I need this article to complete my assignment in the college, and it has same topic with your article. Thanks,corflute signs

Cara Menggugurkan Kandungan || Obat Penggugur Kandungan

Obat Penggugur Kandungan Obat Untuk Menggugurkan Kandungan, Dimana Seorang Wanita Yang Tidak Ingin Kehamilanya Berlanjut. Ada Berbagai Alasan Mengapa Wanita Ingin Tahu Cara Menggugurkan Kandungan

New site is solid. A debt of

New site is solid. A debt of gratitude is in order for the colossal exertion. contact

Demir Leather

Brilliant Information sharing .. This post is genuinely amazing. I genuinely like this post. It is one of the best posts that I ve perused in a long time. Abundantly refreshing for this superior to anything normal post. I really welcome it! Demir Leather

whittier ca financial advisor

You spent years feathering your nest egg: tracking your investments, adjusting your allocation and sacrificing a percentage of your paycheck every month to finance a comfortable retirement. Who knew that would be the easy part. The biggest challenge for people in retirement is recreating the income streams they had when they were working. Therefore, retirees must learn to adapt their withdrawal strategy to a changing tax environment by managing their tax-advantaged accounts, such as IRAs and 401(k) plans.whittier ca financial advisor

Marketing Consultant

Sujit Nair is a B2C / B2B Marketer with extensive experience in digital marketing, brand consulting and corporate marketing. He consults clients from education, healthcare, pharmaceutical, real estate and technology domains. He also does an end-to-end business consulting for start-ups.Marketing Consultant

Ley del consumidor 

Marvelous article! I need individuals to know exactly how great this data is in your article. It's intriguing, convincing substance. Your perspectives are much like my own particular concerning this subject.Ley del consumidor 

desert safari offer

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. desert safari offer

Villas to rent in Ayia Napa

Villas to rent in Ayia Napa, Protaras (mostly with pools) are here for you to relax, in the fine Mediterranean sun and enjoy the lovely beaches in Ayia Napa and Protaras. Quality rental services from http://www.rentvillacyprus.net/search/famagusta/ayia-napa

terminix bed bugs

This is my first time i visit here. I discovered such a large number of fascinating stuff in your web journal particularly its discourse. From the huge amounts of remarks on your articles, I figure I am not by any means the only one having all the satisfaction here! keep doing awesome.terminix bed bugs

Careers Guru

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. Big thanks for the useful info Careers Guru

voyance par telephone

I love it very much.thanks saw this page bookmarked and very much liked what I read. I will surely bookmark it as well and also go through your other posts tonight.Thanks for you sharing! Check this site. voyance par telephone

This is a great inspiring

This is a great inspiring article.I am pretty much pleased with your good work.You put really very helpful information... Hero Instinct

dokdo

Dokdo is an inherent territory of Korea. Dokdo has been a part of Korean territory since 512 AD. Discover the historical facts now. dokdo

Tips Sehat

Thank you for sharing this interesting information. Please also visit our blog, here you can get various interesting information about health and traditional medicine. Obat Amandel Membengkak Pada Anak Yang Aman Manfaat dan Khasiat Daun Mint Bagi Kesehatan Obat Hipertensi Esensial Herbal yang Ampuh dan Aman

21st century workforce

Stations: Changing Your Life - Changing Your Career" is a book of essays that addresses life circumstances that we all experience as children or adults that may affect future and present career options.21st century workforce

pioneerseo

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. https://eubookshophq.wixsite.com/diabetesdestroyer/single-post/2017/04/11/Diabetes-Destroyer-Review-%E2%80%93-Natural-Diabetes-Treatment

brochure printing singapore

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. brochure printing singapore

telephone

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

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