I’ve been investigating the Kalender snippet recently, it’s a great snippet but it could use some work!
Kalender
First thing, the name confused me. If nothing shows up, not even an error, that means you typed in the name wrong. Triple check every letter that you typed for the snippet call. It’s not Kalend
ar, but Kalend
er. I know, I did.
No tooltip
Second problem, overLib throws an error: ’Unterminated litteral’. That’s because the content being passed to the overLib function has \r\n caracters in it. They must be filtered out, so you need to change the following lines in the Kalendar snippet:
Around line 543, change this:
$html.= addslashes(str_replace('"',"'",$monthEvent["description"]));
to this:
$html.= addslashes(str_replace('"',"'",preg_replace('/\r|\n/','',$monthEvent["description"])));
Around line 552, change this:
$html.= addslashes(str_replace('"',"'",$monthEvent["introtext"]));
to this:
$html.= addslashes(str_replace('"',"'",preg_replace('/\r|\n/','',$monthEvent["introtext"])));
Around line 561, change this:
$html.= addslashes(str_replace('"',"'",$monthEvent["content"]));
to this:
$html.= addslashes(str_replace('"',"'",preg_replace('/\r|\n/','',$monthEvent["content"])));
Tooltip is not showing in the right place
There might be another problem. On my template, I’m using a div position:relative to hold my content. This causes the tooltip content to show up way farther than supposed. That’s because, has stated in the overLib documentation, the <div id="overLib"> should be located right after the <body> tag. Here, the solution is to hack the snippet again.
Cut the line, around line 379, that looks like this:
<div id="overDiv" style="position:absolute; visibility:hidden; z-index:1000;"></div>
and paste it in your template, right after your <body> tag. It should cause any problem on other pages since its visibility is hidden. There might be another way around this, but I don’t know it yet
Multilingual Support
Nice addition by Pikachu, the much needed set_locale allows us to get months name in our native language. Unfortunately, I had a problem with accentuated characters showing up as question marks because I was using UTF-8 encoding for my pages. To fix this, either add the utf8_encode() function in the snippet at around line 399, change this:
to this:
<? echo utf8_encode($month); ?>
and around line 661, change this:
$html_jump .= strftime("%B %Y",strtotime($jump_rows_mm."/1/".$jump_rows_yyyy));
to this:
$html_jump .= utf8_encode(strftime("%B %Y",strtotime($jump_rows_mm."/1/".$jump_rows_yyyy)));
Note: If you’re using another ISO character encoding, replace utf8_encode() with htmlentities() or make the switch to UTF8
Well, that’s about it. Otherwise, it’s a great kick start, I’m sure we could team up to make something really great out of it. I would invite deevio to update his code with my changes. I’m just starting with MODx and I just switched from using my home cooked CMS to MODx and I must say that it’s really great. Hope I can contribute sooner than later.
I attached the updated source code for the snippet. The only thing you need to remember is to add the <div id="overLib"> in your template, as mentioned previously in my post. Hope this helps someone.