Drupal

Adding Facebook 'Like' button to your Drupal site

I wanted to look at integrating the Facebook 'Like' button on individual nodes (including a list of nodes using views). I ran across a few resources and found a good starting point. My approach embeds the code within node-{content type}.tpl.php.

Here's my approach...

Code:

<iframe id="iframe_like" name="fbLikeIFrame_0" class="social-iframe" scrolling="no" frameborder="0" src="http://www.facebook.com/widgets/like.php?width=100&amp;show_faces=1&amp;layout=standard&amp;colorscheme=light&amp;href=<?php $curr_url = check_plain("http://" .$_SERVER['HTTP_HOST'] .$node_url); echo $curr_url; ?>" width="100%" height="30"></iframe>

  1. Find an open the node.tpl.php file in your theme folder. If you want to add the like button to each and every node, then edit this file. If you want to add it to certain content types, then you can open that specific node.tpl.php file or simply copy this file and rename to node-{insertContentTypeHere}.tpl.php (for a content type of Video, your file will be named node-video.tpl.php. If that was confusing to you, leave a comment and I'll try to explain further.
  2. We will want to insert the code above between <div class="content"> and <?php print $content ?>
  3. Save and upload your modified file to your server.

You can test it out on using the LIKE button on the top right of this post. Go ahead, give it a shot!

The Facebook like button has two color options. Light and Dark. You can switch by modifying the code above from colorscheme=light to colorscheme=dark.\

Also check out Adding Twitter button to your Drupal site.

Using Node_Import to import products into Ubercart 2.x

I've spent a better part of a few hours looking into node_import + ubercard 2.x and have not had much luck importing correctly.  I'm hoping to get it worked out and blog about how to accomplish the heirarchical category import for products.

Here are a few issues I've been looking at:

When I find the solution, I will update this post.

Drupal Duplicate Entry Comment Issue

Was spinning my wheels today trying to figure out why the comments were not working correctly on my blog.  I was receiving the following error:

"user warning: Duplicate entry '0' for key 1 query: INSERT INTO comments...."

The fix was found here. Evidently it was broken after upgrading from Drupal 5 to Drupal 6.  Simply needed to run the following SQL command:

alter table comments modify cid int(10) auto_increment;

Hope this helps someone else!

DrupalCon SF

So, are you going to DrupalCon SF?  If so, drop me a line!  There will be quite a few Drupal Fresno guys heading up to SF for the geek-filled few days.

Vote for your favorite proposed sessions!