BLOG
Calendar icons revisited - bubble with comment count
My blog-post with calendar icons is nearly one year old. I've seen quite a lot of people using it and was surprised. One of the best upgrades was by Joost de Valk (Yoast.com). His article on CSS-Tricks shows his idea to place a bubble with comment count over the calendar icon. Read how it works and how to implement it in your drupal theme.
![]()
He also made the code more accessible, with adding spans (and hiding them with css), so it will display the date even when visitor has css disabled.
The only problem with this approach is it's using transparent png for bubble icon. So if you want to support IE6 you will have to add a javascript png fix or create your own bubble icon.
You can download calendar icons here: Calendar icons not only for your blog.
The bubble can be downloaded here: Get the bubble
The code below is mostly rewrite of the code from css-tricks.
To display one calendar icon we will use this html:
- <p class="date month8"><span>Aug</span> 18<span>th</span></p>
and css below:
- p.date {
- width: 42px;
- height: 10px;
- padding: 18px 0 14px 0;
- text-align: center;
- }
- p.date span { display: none; }
Calendar icons code
- .month1 { background: url(images/01.gif) no-repeat 0 0; }
- .month2 { background: url(images/02.gif) no-repeat 0 0; }
- .month3 { background: url(images/03.gif) no-repeat 0 0; }
- .month4 { background: url(images/04.gif) no-repeat 0 0; }
- .month5 { background: url(images/05.gif) no-repeat 0 0; }
- .month6 { background: url(images/06.gif) no-repeat 0 0; }
- .month7 { background: url(images/07.gif) no-repeat 0 0; }
- .month8 { background: url(images/08.gif) no-repeat 0 0; }
- .month9 { background: url(images/09.gif) no-repeat 0 0; }
- .month10 { background: url(images/10.gif) no-repeat 0 0; }
- .month11 { background: url(images/11.gif) no-repeat 0 0; }
- .month12 { background: url(images/12.gif) no-repeat 0 0; }
It is now more accessible than my previous code as you can see.
Now to add a comment bubble, Joost wrapped "p" into another div named "shield" and added a div for comment bubble. The final html code will look like:
- <div class="shield">
- <p class="date month8"><span>Aug</span> 18<span>th</span></p>
- <div class="commentscloud">5</div>
- </div>
and it's css
- .shield {
- position: relative;
- }
- .commentscloud {
- position: absolute;
- text-align: center;
- top: -4px;
- left: 22px;
- width: 30px;
- height: 24px;
- padding: 3px 0;
- background: url(images/bubble.png) no-repeat 0 0;
- }
How to implement this in drupal
Put this code into your node.tpl.php.
- $month = t(format_date($node->created,'custom','F'));
- $cal_month = format_date($node->created,'custom','n');
- $day = format_date($node->created,'custom','d');
- $suffix = format_date($node->created,'custom','S');
- $calendar = '<div class="shield">';
- $calendar .= '<p class="date month'.$cal_month.'"><span>'.$month.'</span> '.$day.'<span>'.$suffix.'</span></p>';
- $calendar .= '<div class="commentscloud">'.$node->comment_count.'</div>';
- $calendar .= '</div>';
And then print the $calendar variable.
For drupal 6 the approach would be to place the code into _preprocess_node function. Well you can do similar thing with D5, and use _variables function.
Drupal 6
- <?php
- function phptemplate_preprocess_node(&$variables) {
- $node = $variables['node'];
- $month = t(format_date($node->created,'custom','F'));
- $cal_month = format_date($node->created,'custom','n');
- $day = format_date($node->created,'custom','d');
- $suffix = format_date($node->created,'custom','S');
- $calendar = '<div class="shield">';
- $calendar .= '<p class="date month'.$cal_month.'"><span>'.$month.'</span> '.$day.'<span>'.$suffix.'</span></p>';
- $calendar .= '<div class="commentscloud">'.$node->comment_count.'</div>';
- $calendar .= '</div>';
- $variables['calendar'] = $calendar;
- }
- ?>
Then in your node.tpl.php you just print $calendar wherever you want to display the calendar icon with comment bubble.
You might also want to add a condition, if the language is different than english for not displaying st,nd,th.
And here is the full css code for your style.css
- p.date {
- width: 42px;
- height: 10px;
- padding: 18px 0 14px 0;
- text-align: center;
- }
- p.date span { display: none; }
- .month1 { background: url(images/01.gif) no-repeat 0 0; }
- .month2 { background: url(images/02.gif) no-repeat 0 0; }
- .month3 { background: url(images/03.gif) no-repeat 0 0; }
- .month4 { background: url(images/04.gif) no-repeat 0 0; }
- .month5 { background: url(images/05.gif) no-repeat 0 0; }
- .month6 { background: url(images/06.gif) no-repeat 0 0; }
- .month7 { background: url(images/07.gif) no-repeat 0 0; }
- .month8 { background: url(images/08.gif) no-repeat 0 0; }
- .month9 { background: url(images/09.gif) no-repeat 0 0; }
- .month10 { background: url(images/10.gif) no-repeat 0 0; }
- .month11 { background: url(images/11.gif) no-repeat 0 0; }
- .month12 { background: url(images/12.gif) no-repeat 0 0; }
- .shield {
- position: relative;
- }
- .commentscloud {
- position: absolute;
- text-align: center;
- top: -4px;
- left: 22px;
- width: 30px;
- height: 24px;
- padding: 3px 0;
- background: url(images/bubble.png) no-repeat 0 0;
- }
Don't forget to place the calendar icons into images folder within your theme or change the code. Same applies for the bubble image.
| Attachment | Size |
|---|---|
| bubble.png | 1.82 KB |




It really looks very good, I would also like to do this at my blog.
What's missing here? There is/are missing step(s) here. I'm using Drupal 6 and trying to use this, but there seems to be an additional tpl.php file or something. What am I missing here?
@Rob - phptemplate_preprocess_node should be in a template.php in Drupal 6, then print the variable $calendar in node.tpl.php
All Web Partners
Seo Silvershine Company
The best platform already in this situation MCITP | MCTS
It looks very good, I want to do it on my blog.
Logo Design | website design
Thanks for this great CSS & script , ive installed it onto one of my blog management services blogs and it looks fantastic!
The calendar icons are simply stunning, have used them in the past and am planning to do so again on my Fifa world cup betting odds site as well.
Interesting. Thanks for sharing.
stromanbieter wechseln paderborn
This looks great thanks, I installed Cloud Security to help keep my website clean and no I am scouring the internet for ways to make the look really nice and inviting but functional too.
Bosch Buzdolab? So?umutuyor? Bosch servisi nerde? En yak?n Bosch Bayisi? Bosch Servis olarak ?stanbul?un tüm semtlerine hizmet vermekteyiz.
Ar?zal?, bak?ma ihtiyac? olan bosch markal? cihazlar?n?z? Bosch Servisi olarak günümüzün son teknolojileri ile tamir ediyoruz.
Bosch Beyaz Eşya Al?rken Neye göre seçim yapmal?y?m?
Beyaz eşya al?rken, ihtiyaçlar?n?z? en üst seviyede karş?layacak şekilde seçim yapmal?s?n?z. Ürünle ilgili beklentilerinizi bayiye net olarak iletmelisiniz. Ürünün, reklam?nda veya tan?t?c? broşüründe belirtilen özellikleri taş?y?p taş?mad???n? kontrol etmelisiniz. Bosch Servisi yan?lt?c? ibareler içeren veya gerçe?i yans?tmayan ürünler ay?pl? mald?r.
Bosch Buzdolab? Çal?şm?yorsa ?
Buzdolab?n?z çal?şm?yorsa yapaca??n?z işlem bosch servisi ça??rmakt?r.Bize ulaşmak için http://boschservisin.net adl? internet sitemize girebilir veya 444 1 784 numaral? telefondan bize ulaş?p ar?za kayd? açt?rabilirsiniz.
Bosch Kombi Çal?şm?yorsa ?
Kombiniz çal?şm?yorsa yapman?z gereken 444 1 784 numaral? ça?r? merkezimizden bize ulaşmak veya boschservisin.net ?den ar?za kayd? oluşturmakt?r.
Firmam?z S.M. Mali Müşavirlik Bürosu; Meslekte uzun y?llara dayanan deneyimli kurucu kadrosu ve çal?şanlar? ile 14 y?ld?r Avc?lar?da faaliyetine devam etmektedir.
Devlet ad?na, belli bir ciroya ulaşm?ş firmalar?n hizmetini almakta zorunda oldu?u, o firman?n muhasebe ve mali kay?tlar?n? kontrol etme yetkisine sahip ve bu firmalardan belli bir ücret almay? hakeden şah?slara mali müşavir denir. Hizmetlerimiz hakk?nda daha detayl? bilgi almak için bizimle iletişime geçebilirsiniz.
istanbul franke servisi
istanbul avrupa ve anadolu kombi servisi
thank you nice post
http://mieleservisin.com/miele-servisi/
plus teknik gaggenau servisi. ankastre ve beyaz eşya
kimya ürünleri üzerine köpük kesici ürünleri üretmekteyiz.
bosch kombi servis hizmetleri. bak?m ve ar?za servisi.
istanbul panasonic klima bak?m ve montaj servisi
avc?lar arçelik beyaz eşya servisi
bak?rköy bosch ankastre ve beyaz eşya servisi
bosch marka ankastre servisi
cnc plazma kesim hizmetleri kumru demir çelik
cnc plazma kesim hizmetleri kumru demir çelik
bosch istanbul buzdolab? servisi
thank you nice post for bubble
Very informative and helpful post. You have good command on the topic and have explained in a very nice way. Thanks for sharing.
[url=http://www.oyunkedi.com]oyun oyna[/url]
ümraniye vaillant servisi
Such a great service that you should try!
üsküdar buderus servisi
[url="http://www.gamaoyun.com"]oyun oyna[/url]
[url="http://www.gamaoyun.com"]oyun oyna[/url]
[url=http://www.gamaoyun.com]oyun oyna[/url]
[url=http://www.gamaoyun.com]oyun oyna[/url]
I love your calendar icons that's why the script and CSS codes are very useful for me. Thanks, by the way. I've placed it on my other blog. They are just simply fantastic!
tahiti beach homes
Very nice tutorial. I am looking forward to implement that calender icon with my blog as well. Thanks and keep posting such knowledgeable tutorials. Thanks again.
HelpFixAnyPC Laptop Repair Leicester
Submit Link | Free Directory Submission
how to prevent fire
I am very pleased to study this article. I will surely be back again to look at some other important posts that you have in future. I wanted to thank you for this great blog.essay term paper
Cool post, very interesting information!
lbps loan modification
The post is written in very a good manner and it entails many useful information for me. I am happy to find your distinguished way of writing the post.
Web Shopping Cart
Post new comment