Do you have a custom Content Management System (CMS) and wanted to include a handy way for your viewers to link to many of the popular social bookmarking sites like Ma.gnolia.com, Technorati or Digg? Many of the popular blogging applications (drupal, WordPress, etc) have plugins for this, but I wrote my own function, since I don't normally use those applications. I thought I'd pass it along to anyone that is interested.
First you will need to download a zip archive of png images. You can download that here.
Next, we'll need to create a database table to store our bookmark information. This will store linkage format, image and bookmark site. We will treat our URLs as templates, with placeholders for URL and your blog title.
CREATE TABLE `bookmarks` (
`MarkID` int(11) NOT NULL auto_increment,
`Bookmark` varchar(200) NOT NULL,
`Image` varchar(200) NOT NULL,
`URL` varchar(255) NOT NULL,
`Active` tinyint(4) NOT NULL default '1',
PRIMARY KEY (`MarkID`)
) ENGINE=MyISAM AUTO_INCREMENT=25 DEFAULT CHARSET=latin1 AUTO_INCREMENT=25 ;
--
-- Dumping data for table `bookmarks`
--
INSERT INTO `bookmarks` VALUES (1, 'Del.icio.us', 'delicious.png', 'http://del.icio.us/post?url=#URL#&title=#TITLE#', 1);
INSERT INTO `bookmarks` VALUES (2, 'digg', 'digg.png', 'http://digg.com/submit?phase=2&url=#URL#&title=#TITLE#', 1);
INSERT INTO `bookmarks` VALUES (3, 'FURL', 'furl.png', 'http://furl.net/storeIt.jsp?t=#TITLE#&u=#URL#', 1);
INSERT INTO `bookmarks` VALUES (4, 'blinklist', 'blinklist.png', 'http://blinklist.com/index.php?Action=Blink/addblink.php&Name=#TITLE#&Description=#TITLE#&Url=#URL#', 1);
INSERT INTO `bookmarks` VALUES (5, 'reddit', 'reddit.png', 'http://reddit.com/submit?url=#URL#&title=#TITLE#', 1);
INSERT INTO `bookmarks` VALUES (6, 'Feed Me Links', 'feedmelinks.png', 'http://feedmelinks.com/categorize?from=toolbar&op=submit&name=#TITLE#&url=#URL#&version=0.7', 1);
INSERT INTO `bookmarks` VALUES (7, 'Technorati', 'technorati.png', 'http://www.technorati.com/faves?add=#URL#', 1);
INSERT INTO `bookmarks` VALUES (8, 'Yahoo My Web', 'yahoo_myweb.png', 'http://myweb2.search.yahoo.com/myresults/bookmarklet?u=#URL#&t=#TITLE#', 1);
INSERT INTO `bookmarks` VALUES (9, 'Newsvine', 'newsvine.png', 'http://www.newsvine.com/_wine/save?u=#URL#&h=#TITLE#', 1);
INSERT INTO `bookmarks` VALUES (10, 'Socializer', 'socializer.png', 'http://ekstreme.com/socializer/?url=#URL#&title=#TITLE#', 1);
INSERT INTO `bookmarks` VALUES (11, 'Ma.gnolia', 'magnolia.png', 'http://ma.gnolia.com/bookmarklet/add?url=#URL#&title=#TITLE#', 1);
INSERT INTO `bookmarks` VALUES (12, 'Stumble Upon', 'stumbleupon.png', 'http://www.stumbleupon.com/refer.php?url=#URL#&title=#TITLE#', 1);
INSERT INTO `bookmarks` VALUES (13, 'Google Bookmarks', 'google.png', 'http://www.google.com/bookmarks/mark?op=edit&output=popup&bkmk=#URL#&title=#TITLE#', 1);
INSERT INTO `bookmarks` VALUES (14, 'RawSugar', 'rawsugar.png', 'http://www.rawsugar.com/tagger/?turl=#URL#&tttl=#TITLE#', 1);
INSERT INTO `bookmarks` VALUES (15, 'Squidoo', 'squidoo.png', 'http://www.squidoo.com/lensmaster/bookmark?#URL#', 1);
INSERT INTO `bookmarks` VALUES (16, 'Spurl', 'spurl.png', 'http://www.spurl.net/spurl.php?url=#URL#&title=#TITLE#', 1);
INSERT INTO `bookmarks` VALUES (17, 'BlinkBits', 'blinkbits.png', 'http://blinkbits.com/bookmarklets/save.php?v=1&source_url=#URL#&title=#TITLE#', 1);
INSERT INTO `bookmarks` VALUES (18, 'Netvouz', 'netvouz.png', 'http://netvouz.com/action/submitBookmark?url=#URL#&title=#TITLE#&popup=no', 1);
INSERT INTO `bookmarks` VALUES (19, 'Rojo', 'rojo.png', 'http://www.rojo.com/add-subscription/?resource=#URL#', 1);
INSERT INTO `bookmarks` VALUES (20, 'Blogmarks', 'bmarks.png', 'http://blogmarks.net/my/new.php?mini=1&simple=1&url=#URL#&title=#TITLE#', 1);
INSERT INTO `bookmarks` VALUES (21, 'Shadows', 'shadows.png', 'http://www.shadows.com/shadows.aspx?url=#URL#', 1);
INSERT INTO `bookmarks` VALUES (22, 'Simpy', 'simpy.png', 'http://www.simpy.com/simpy/LinkAdd.do?href=#URL#&title=#TITLE#', 1);
INSERT INTO `bookmarks` VALUES (23, 'Co.mments', 'comments.png', 'http://co.mments.com/track?url=#URL#&title=#TITLE#', 1);
INSERT INTO `bookmarks` VALUES (24, 'Scuttle', 'scuttle.png', 'http://www.scuttle.org/bookmarks.php/maxpower?action=add&address=#URL#&title=#TITLE#', 1);
I wanted to write a function which expects some parameters and dynamically loops through all of our bookmarks in our database. It will create the proper links to the bookmark site and display our nice little linkable icons.
<?
function socialBookmarks($inTitle, $inURL){
global $connect,$rootpath,$webroot;
$fSQL = "SELECT *
FROM bookmarks
WHERE Active = 1";
if(!$fRS = mysql_query($fSQL,$connect)){
echo "Database Error";exit();
}
$origTitle = $inTitle;
while($fROW = mysql_fetch_object($fRS)){
$target = $fROW->URL;
$outImage = $fROW->Image;
$outBookmark = $fROW->Bookmark;
$inTitle = urlencode(sanitize($inTitle));
$outURL = str_replace("#TITLE#",$inTitle,$target);
$outURL = str_replace("#URL#",$inURL,$outURL);?>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="<?=$outURL?>" title="<?=$origTitle?>' to <?=$outBookmark?>"><img src="images/social_bookmarks/<?=$outImage?>" title="Add '<?=$origTitle?> to <?=$outBookmark?>" alt="Add '<?=$origTitle?>' to <?=$outBookmark?>" border=0/></a>
<?}
mysql_free_result($fRS);
}
?>
This function will accept our blog Title and the URL for our blog entry. It will loop through the bookmark recordset and replace #TITLE# with our title and #URL# with our URL. To call this function below your blog entry do the following:
<?
echo "<em>Bookmark to:</em><br />";
$url = "http://yourblog.com?ID=".$ID;
socialBookmarks($BlogTitle,$url)
?>
Hope you find this useful!
Go Back
|
This is great Mike | 12/02/06 at 11:35PM Thanks for posting this!!! |
|
I'm rollin' with social bookmarks now! PHP-nut | 12/11/06 at 08:59AM This is just what I was looking for. It was a snap to get going. Thanks much!!!!! |
|
cool Tomas | 12/24/06 at 7:39PM You have Excellent site, added to favorites!! |
|
cool Sandro | 12/25/06 at 09:38AM Thank you for your site. Useful information. |
|
Awesome Verosvbd | 01/24/07 at 10:11PM This site is great! |
|
Interesting post davidvogt | 02/03/07 at 4:28PM Your article is very informative and helped me further. Thanks, David |
|
Managgeres Managgeres | 03/04/07 at 8:28PM Great Site! |
|
Unknown robert | 03/19/07 at 03:43AM hi all. nice blog. its very ineresting article. |
|
Unknown alex | 04/11/07 at 1:31PM hi nice site. |
|
Unknown alex | 04/13/07 at 2:45PM hi nice site. |
|
Unknown alex | 04/15/07 at 11:40PM hi nice site. |
|
utcszksahs utcszksahs | 08/22/07 at 3:48PM Thanks for this site! a href=http://mvp.ovxxt.cn/upwil.htmlhttp://mvp.ovxxt.cn/upwil.html/a a href=http://aujs.unquz.cn/dpbsdnz.htmlhttp://aujs.unquz.cn/dpbsdnz.html/a a href=http://me.vcbdm.cn/nddesweuw.htmlhttp://me.vcbdm.cn/nddesweuw.html/a a href=http://djky.jclsf.cn/vdeexljpyy.htmlhttp://djky.jclsf.cn/vdeexljpyy.html/a a href=http://vlb.ozjyi.cn/pidtf.htmlhttp://vlb.ozjyi.cn/pidtf.html/a a href=http://ppw.iqzaw.cn/dyyavvgy.htmlhttp://ppw.iqzaw.cn/dyyavvgy.html/a a href=http://lq.srths.cn/uquvisocrf.htmlhttp://lq.srths.cn/uquvisocrf.html/a a href=http://nri.aeyzf.cn/zhqlkznfhb.htmlhttp://nri.aeyzf.cn/zhqlkznfhb.html/a a href=http://txfk.krumo.cn/klxi.htmlhttp://txfk.krumo.cn/klxi.html/a a href=http://yw.qydph.cn/pnzre.htmlhttp://yw.qydph.cn/pnzre.html/a a href=http://sta.njpgv.cn/ucsxgimfl.htmlhttp://sta.njpgv.cn/ucsxgimfl.html/a a href=http://zp.lbava.cn/oyrxuen.htmlhttp://zp.lbava.cn/oyrxuen.html/a a href=http://tvod.hcant.cn/fpsitdsi.htmlhttp://tvod.hcant.cn/fpsitdsi.html/a a href=http://tv.vxcoo.cn/ksgx.htmlhttp://tv.vxcoo.cn/ksgx.html/a a href=http://ppw.iqzaw.cn/retbaiqe.htmlhttp://ppw.iqzaw.cn/retbaiqe.html/a a href=http://la.uwcns.cn/nikczoh.htmlhttp://la.uwcns.cn/nikczoh.html/a a href=http://sjhw.fzdpk.cn/kolclvbqe.htmlhttp://sjhw.fzdpk.cn/kolclvbqe.html/a a href=http://la.uwcns.cn/vglsp.htmlhttp://la.uwcns.cn/vglsp.html/a a href=http://me.vcbdm.cn/ssmxqe.htmlhttp://me.vcbdm.cn/ssmxqe.html/a a href=http://gngq.filun.cn/crlmazx.htmlhttp://gngq.filun.cn/crlmazx.html/a a href=http://lq.srths.cn/isglgk.htmlhttp://lq.srths.cn/isglgk.html/a a href=http://nzag.owhwz.cn/knlhizi.htmlhttp://nzag.owhwz.cn/knlhizi.html/a a href=http://gngq.filun.cn/njsa.htmlhttp://gngq.filun.cn/njsa.html/a a href=http://ppw.iqzaw.cn/wlqrkyeo.htmlhttp://ppw.iqzaw.cn/wlqrkyeo.html/a a href=http://qfzh.pixvf.cn/honk.htmlhttp://qfzh.pixvf.cn/honk.html/a |
|
fdxhfarmam fdxhfarmam | 06/13/07 at 07:20AM This was very helpful. Just added social bookmarks to my site! Thanks!!! |
|
Great Article.. and a question Mike | 07/08/07 at 5:24PM Great article on Social Bookmarks. Can you put something together on comment spam prevention? Are you using Akismet or something else?? Mike |
|
thanks Goxiukkk | 07/11/07 at 3:49PM very interesting |
|
vnswmbbxsn vnswmbbxsn | 08/21/07 at 00:19AM Thanks for this site! |
|
sicatfyoap sicatfyoap | 08/22/07 at 06:37AM Thanks for this site! |
|
DevSnips spammer | 07/28/07 at 5:51PM Great site! |
