How to Add the Facebook Like Button to ELGG / PLIGG / WordPress – Dynamic Urls
June 4, 2010 by admin
Filed under Business Management, Viral Marketing: Facebook Twitter Youtube
This took a bit of time to figure out. Once you know how, it’s super easy. Since all the pages in ELGG / PLIGG or any CMS are dynamically generated in PHP, all you have to do is add php code that triggers the physical url into the facebook pluggin. So instead of entering http://DisastEarth.com in the URL field at http://developers.facebook.com/docs/reference/plugins/like … you’d enter {$story_url}
BUT DON’T.
Although PLIGG uses {$story_url} to reference urls, ELGG, and other CMSs may not. So… to find out what php code your CMS like WordPress or Drupal uses, just open up one of your site template pages and look for <a href=”THISisTHEphpCODEyouNEED”
You’re not done yet.
Do NOT put the THISisTHEphpCODEyouNEED or {$story_url} in the facebook plugins builder wizard. It’ll render these characters, “{$}” into their HTML code. You need these characters as-is – NOT converted to html code. So, just go into your html text editor and add {$story_url} or THISisTHEphpCODEyouNEED instead of the static url:
So, like.php?href=http%253A%252F%252Fdisastearth.com%252F
becomes like.php?href={$story_url} or like.php?href={THISisTHEphpCODEyouNEED
Here’s the last step. If your facebook like button still doesn’t work, the reason is simple. THISisTHEphpCODEyouNEED may just generate a partial url like http://story.php?title=a-bp-gulf-oil-spill-photo-i-will-never-forget-tedchris … it’s missing the domain name. So.. just add: http://disastearth.com/ right in front of THISisTHEphpCODEyouNEED. If you do it right, in PLIGG, it looks like this:
like.php?href=http%253A%252F%252Fdisastearth.com{$story_url}


