I've got tweetmeme setup and integrated with a custom event node (using CCK date). I also use the Calendar module to display the event nodes. When clicking on events in the year, month, week, day views, the event is supposed to show up in a little preview bubble, but with tweetmeme enabled for the event node, the little popup window starts to show up and then the page refreshes and only shows the tweetmeme bubble. (see attached)

I can view the events individually (outside of the calendar) and the tweetmeme bubble shows up and works fine.

Comments

steven jones’s picture

Title: Problem integrating with Calendar module » Tweetmeme not compatible with AHAH content

We are seeing this exact issue, but when previewing a view. The JS that tweetmeme provide doesn't seem compatible with drupal AHAH stuff.

steven jones’s picture

So it turns out that the js that you have to include from tweetmeme:
http://tweetmeme.com/i/scripts/button.js
Includes a nasty document.write() causing the page to be replaced with just the tweetmeme button when run from any other scope than the initial page load.

Our (not ideal) solution is to have a local copy of the tweetmeme script and tweak it to use jQuery.

So, you'll want to override the theme_tweetmeme_button() with this:

/**
 * Displays the TweetMeme button.
 *
 * This fixes issue: #571938 and means that tweetmeme
 * buttons can work when AHAH'd onto a page.
 */
function theme_tweetmeme_button($url, $style = 'normal') {
  $id = md5(uniqid(mt_rand(), TRUE));
  drupal_add_css(drupal_get_path('module', 'tweetmeme') . '/tweetmeme.css');
  $output = '<div class="tweetmeme tweetmeme-button" id="tweetmeme-widget-' . $id . '"><script type="text/javascript">tweetmeme_url = "' . $url . '";';
  if ($style != 'normal') {
    $output .= "tweetmeme_style = '$style';";
  }
  $output .= "tweetmeme_element_id = '#tweetmeme-widget-$id';";
  $output .= '</script>';
  //$output .= '</script><script type="text/javascript" src="http://tweetmeme.com/i/scripts/button.js"></script></div>';
  $output .= '<script type="text/javascript" src="' . base_path() . drupal_get_path('theme', 'theme_name') . '/js/button.js' . '"></script></div>';
  
  return $output;
}

And then copy the button.js from the tweetmeme server to your local server, and change the document.write line (might want to JS beautify the code so you can see what you're doing) to this:

$(tweetmeme_element_id).append('<iframe src="' + src + '" height="' + h + '" width="' + w + '" frameborder="0" scrolling="no"></iframe>');

robloach’s picture

Version: 6.x-1.2 » 6.x-1.x-dev

I brought this up to them a while ago and they suggested using the iFrame directly:
http://help.tweetmeme.com/forum/topic/64#post-240

I think what you suggest is a better solution/hack though. It also means we could stick the JavaScript at the bottom of the page.

mrfelton’s picture

I have this problem too when trying to update, preview, or save a view - page refreshes to completely whitescreen. I don't see the tweetmeme image, but I do see that it's trying to contact tweetmeme in the browser's status bar. I also seem to have the same or similar problem with the addthis module.

Where possible, remote resources should be stored locally - this is much better from a performance point of view.

mrfelton’s picture

Status: Active » Needs review
StatusFileSize
new3.05 KB

Attached is a patch that incorporates the above fix AND includes the js file in the module directory, so no need to download it and put it in your theme directory. Not sure of the licence of the tweetmeme script though, so that may be a no go.

mrfelton’s picture

StatusFileSize
new3.17 KB

Oops. Bad patch - IGNORE THE PATCH ABOVE. forgot to comment out the original code! Use this one instead.

mrfelton’s picture

StatusFileSize
new3.2 KB

Damn it. Really sorry for the multiple posts... forgot to alter the js that time!

DrupalSza’s picture

I'm facing this issue as well.

Using TweetMeme w/calendar views causes a white screen, or when creating a view w/a node type that uses tweetmeme also causes a white screen.

Does this patch still work?

If so - how would I install it?

I have never used a patch before.

Thank you.

kmonty’s picture

Sub. I'm having this issue and would love to test but this patch is old and don't have time to update it (deadline Sunday!). If someone redoes this patch based on dev, I'll happy report back.

robloach’s picture

I like this, but am concerned what would happen if they change their service or their JavaScript changes. It's nice to be able to aggregate the JavaScript, but I'm not sure if we want to assume their JavaScript will never change.

There's also #751374: Use TweetMeme API instead of JavaScript which might be a better solution.

mrfelton’s picture

StatusFileSize
new1.46 KB

I know this is not the preferred solution, but we needed an updated patch to apply to 1.3 to get things working, and we needed it now, so it was quick and easy for us to just update this patch./ Revised version attached.