By JennySmith on
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.....
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.
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:
Then use $uri everywhere in the above code that uses REQUEST_URI.
--
Drupal performance tuning and optimization, hosting, development, and consulting: 2bits.com, Inc. and Twitter at: @2bits
Personal blog: Ba
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.