Posted by JennySmith on September 20, 2008 at 1:40am
The Service Links module does this to the nth degree, but here is some code if you are looking simple way to drop in social networking links.
<A target="_new" HREF="http://digg.com/submit?url=<?php print $GLOBALS['base_url'].'/'; print $path; ?>&title=<?php print $title; ?>"> Digg</A>
<A target="_new" HREF="http://del.icio.us/post?url=<?php print $GLOBALS['base_url'].'/'; print $path; ?>title=<?php print $title; ?>">del.icio.us</A>
<A target="_new" HREF="http://reddit.com/submit?url=<?php print $GLOBALS['base_url'].'/'; print $path; ?>title=<?php print $title; ?>">Reddit</A>
<A target="_new" HREF="http://www.myspace.com/Modules/PostTo/Pages/?t=<?php print $title; ?>&c=&u=<?php print $GLOBALS['base_url'].'/'; print $path; ?>&l=5">MySpace</A>
<A target="_new" HREF="http://www.facebook.com/sharer.php?u=<?php print $GLOBALS['base_url'].'/'; print $path; ?>&t=<?php print $title; ?>">Facebook</A>
Comments
LIttle bit better
Discovered that the above doesn't work in all situations. This code should work better.....
<A HREF="http://digg.com/submit?url=<?php print $GLOBALS['base_url'].'/'; if ($path) { print $path; } if (!$path) { print 'node/'.$nid; } ?>&title=<?php print $title; ?>&bodytext=&media=&topic=">Digg</A>
<A HREF="http://del.icio.us/post?url=<?php print $GLOBALS['base_url'].'/'; if ($path) { print $path; } if (!$path) { print 'node/'.$nid; } ?>title=<?php print $title; ?>">del.icio.us</A>
<A HREF="http://reddit.com/submit?url=<?php print $GLOBALS['base_url'].'/'; if ($path) { print $path; } if (!$path) { print 'node/'.$nid; } ?>title=<?php print $title; ?>">Reddit</A>
<A HREF="http://www.myspace.com/Modules/PostTo/Pages/?t=<?php print $title; ?>&c=&u=<?php print $GLOBALS['base_url'].'/'; if ($path) { print $path; } if (!$path) { print 'node/'.$nid; } ?>&l=5">MySpace</A>
<A target="_new" HREF="http://www.facebook.com/sharer.php?u=<?php print $GLOBALS['base_url'].'/'; if ($path) { print $path; } if (!$path) { print 'node/'.$nid; } ?>&t=<?php print $title; ?>">Facebook</A>
===
LDS Clipart: http://www.mormonshare.com/search-lds-clipart.php
LDS Young Women: http://www.mormonshare.com/young-women
Easiest way for me
I dont know if this is the Drupal way, but I found that using $_SERVER['REQUEST_URI'] was the easiest way. With this method, you do not have to worry about path aliases or node/nid.
<?php$title = drupal_get_title();
$path_to_images = 'sites/all/media/share_icons/'; //This will need to be changed
?>
<table width="369" border="0" cellpadding="10">
<tr>
<td><div align="center"><a href="http://www.facebook.com/sharer.php?u=<?php global $base_root;
print $base_root; print $_SERVER['REQUEST_URI']; ?>&t=<?php print $title; ?>" target="_blank"><img src="<?php
global $base_path; print $base_path; ?><?php print $path_to_images; ?>facebook-logo.gif" alt="Facebook" width="50" height="50"><br>
Facebook<br>
</a></div></td>
<td><div align="center"><a href="http://del.icio.us/post?url=<?php global $base_root;
print $base_root; print $_SERVER['REQUEST_URI']; ?>&title=<?php print $title; ?>" target="_blank"><img src="<?php
global $base_path; print $base_path; ?><?php print $path_to_images; ?>icon-delicious.gif" alt="Del.icio.us" width="50" height="50"><br>
Del.icio.us</a></div></td>
<td><div align="center"><a href="http://digg.com/submit?url=<?php global $base_root;
print $base_root; print $_SERVER['REQUEST_URI']; ?>&title=<?php print $title; ?>&bodytext=&media=&topic=" target="_blank"><img src="<?php
global $base_path; print $base_path; ?><?php print $path_to_images; ?>icon-digg.gif" alt="DIGG" width="50" height="50"><br>
Digg</a></div></td>
<td><div align="center"><a href="http://reddit.com/submit?url=<?php global $base_root;
print $base_root; print $_SERVER['REQUEST_URI']; ?>&title=<?php print $title; ?>" target="_blank"><img src="<?php
global $base_path; print $base_path; ?><?php print $path_to_images; ?>icon-reddit.gif" alt="Reddit" width="50" height="50"><br>
Reddit</a></div></td>
<td><div align="center"><a href="http://www.stumbleupon.com/submit?url=<?php global $base_root;
print $base_root; print $_SERVER['REQUEST_URI']; ?>%26title%3D<?php print $title; ?>" target="_blank"><img src="<?php
global $base_path; print $base_path; ?><?php print $path_to_images; ?>icon-stumble.gif" alt="Stumble" width="50" height="50"><br>
Stumble</a></div></td>
<td><div align="center"><a href="http://www.myspace.com/Modules/PostTo/Pages/?t=<?php print $title; ?>&c=&u=<?php global $base_root;
print $base_root; print $_SERVER['REQUEST_URI']; ?>&l=5" target="_blank"><img src="<?php
global $base_path; print $base_path; ?><?php print $path_to_images; ?>myspace_logo.gif" width="50" height="50"><br>
Myspace</a></div></td>
</tr>
</table>
Tim Piche
recently designed sites:
www.drnina.com
www.nacecare.com
www.haltonhockeyacademy.ca
www.ntfb.ca
www.weblinxx.ca
This code is insecure
This code is not secure as it is posted above.
The reason is that it outputs user input unfiltered, and therefore is a conduit for Cross Site Scripting (XSS) attacks.
The proper way is to do this:
<?php$uri = urlencode($_SERVER['REQUEST_URI']);
?>
Then use $uri everywhere in the above code that uses REQUEST_URI.
--
Drupal performance tuning, development, customization and consulting: 2bits.com, Inc.
Personal blog: Baheyeldin.com.
That too. Furthermore &c=&u
That too.
Furthermore
&c=&uetc is not valid in HTML. This should be&c=&u.Simply check_plain the entire URL.
--
The Manual | Troubleshooting FAQ | Tips for posting | How to report a security issue.