An AddToAny Kludge For Drupal

AddtoAny is a cool widget. For Drupal 6, there is the AddToAny project (http://drupal.org/project/addtoany). It's good. It's really granular in its ability to control access and features. For me, though, the mambo of the Page Title, CCK and AddToAny gave my install indigestion. I knew that I wanted all nodes to show off the AddToAny widget, permissions didn't enter into, and I knew exactly where in the theming I wanted it to appear. So, rather than add one more module to the mix, instead I put the code directly into the theming for content-field. Bad form? Maybe, but that's what makes me a Drupal heretic.

$link_name = $node->title;
$link_url = url('node/' . $node->nid, array('absolute' => 1));

$addany = '<!-- AddToAny BEGIN --><a class="a2a_dd" href="http://www.addtoany.com/share_save?';
$addany .= "linkurl=".urlencode($link_url);
$addany .= "&linkname=".urlencode($link_name);
$addany .= '"><img src="http://static.addtoany.com/buttons/share_save_171_16.png" width="171" height="16" border="0" alt="Share/Bookmark" /></a>'."\n";
$addany .= '<script type="text/javascript">'."\n";
$addany .= 'var a2a_config = a2a_config || {};'."\n";
$addany .= 'a2a_config.linkname = "'.$link_name.'";'."\n";
$addany .= 'a2a_config.linkurl = "'.$link_url.'";'."\n";
$addany .= 'a2a_config.onclick = 1;'."\n";
$addany .= 'a2a_config.show_title = 1;'."\n";
$addany .= 'a2a_config.num_services = 20;'."\n";
$addany .= '</script>'."\n";
$addany .= '<script type="text/javascript" src="http://static.addtoany.com/menu/page.js"></script>'."\n";
$addany .= '<!-- AddToAny END -->';

print $addany;

Comments