Adding LinkedIn and Facebook badges to user profile
Task · How to add LinkedIn/Facebook badges · Site administrators · Site users · Themers · Drupal 6.x · No known problems
Last modified: August 25, 2009 - 02:53
PLEASE NOTE! These snippets are user submitted. It is impossible to check them all, so please use at your own risk! For users who have setup drupal using an alternate database to the default (MYSQL), please note that the snippets may contain some database queries specific to MYSQL.
Description
This php snippet displays custom User Profile URL fields. If the user has not specified any link, it displays nothing.
Dependencies: profile.module
LinkedIn badge
- Enable the profile module by visiting administer >> site building >> modules
- Create a profile URL field
- Visit the Linkedin badge URL: http://www.linkedin.com/profile?promoteProfile
- Pick the LinkedIn badge you want to use, and paste the URL you want to use in your created URL field; for example: http://www.linkedin.com/pub/x/xxx/xxx
- See the instructions on handling URL fields at http://drupal.org/node/35779
Add the script from the above URL to the user-profile.tpl.php file:
<?php if($account->profile_linkedin):?>
<a href="<?php print $account->profile_linkedin ?>"><img src="http://www.linkedin.com/img/webpromo/btn_viewmy_160x33.gif" width="160" height="33" border="0" alt="View <?php print $user->name ?>'s profile on LinkedIn"></a>
<?php endif ?>Possible user profile page after adding the script to profile template:
Facebook badge
- Enable the profile module by visiting administer >> site building >> modules
- Create a profile URL field
- Create a badge in Facebook, by visiting www.facebook.com/badges.php and following the instructions at http://azlan.anilezfa.com/create-a-facebook-badge-for-your-website
- Pick the Facebook url from the Facebook badge you created and paste it into your created URL field; for example: http://www.facebook.com/people/xxx/xxx
- See the instructions on handling URL fields at http://drupal.org/node/35779
Add the script from the above URL to user-profile.tpl.php
<?php if($account->profile_facebook):?>
<a href="<?php print $account->profile_facebook ?>" title="<?php print $user->name ?>'s Facebook profile" target=_TOP><img src="http://badge.facebook.com/badge/1465145637.42.1738780586.png" border=0 alt="<?php print $user->name ?>'s Facebook profile"></a>
<?php endif ?>