Home > Tools > CMS > Drupal > Drupal Hacks > Add an Interactive yigg.de Button in Your Theme

Add an Interactive yigg.de Button in Your Theme

yigg.de is a German language social news community that resembles digg.com in many aspects. To add an interactive yigg.de button (also see diggthis), I added the following code in my theme:

in template.php add

<?php
function mytheme_yiggbutton($nid) {
 
$url = url('node/'.$nid, NULL, NULL, TRUE);
$output =<<<EOF
<div class="yiggbutton">
  <script>
    yigg_url = '$url';
  </script>
  <script src="http://yigg.de/emb_ycount.js"></script>
</div>
EOF;

  return
$output;
?>

in node.tpl.php add

<?php
if ($page != 0 && in_array($node->type, array('blog','video','image'))) {
    print
mytheme_yiggbutton($node->nid);
}
?>

This will display the yigg.de button if the node is a blog, a video or an image.

Live Example