Mar262009
给网站上加收藏到网摘的功能(drupal)
最近主站(extjs.org.cn)的流量虽然一直在上升,但是上升的很慢.有个会员 kennie 写信给我,说能不能为网站加上一个收藏到网摘的功能.一个一个复制来复制去太麻烦了.
其实很久之前一直都打算加上这一个功能,只是……,原因过多. 之前一个好朋友 Peter有跟我提到过他的网站刚刚加了一个网摘的功能.于是乎就用顺手牵羊的方法,把 Peter 网站(joomlar.cn) 的网摘功能偷过来了.
没花10分钟,就把这一个功能加在我用drupal的主站上了.步骤也很简单,只需要在 /themes/yourthemes/node.tpl.php 中加入以下代码.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | <?php if ($page != 0) { ?> <div id="digest"> <b>收藏到网摘:</b> <a href="javascript:d=document;t=d.selection?(d.selection.type!='None'?d.selection.createRange().text:''):(d.getSelection?d.getSelection():'');void(yesky=window.open('http://hot.yesky.com/dp.aspx?t='+escape(d.title)+'&u='+escape(d.location.href)+'&c='+escape(t)+'&st=2','yesky','scrollbars=yes,width=700,height=600,left=75,top=20,status=yes,resizable=yes'));yesky.focus();"><img height="16" alt="天极网摘" src="http://www.extjs.org.cn/misc/digest/yesky.gif" width="16" border="0">天极</A> <a href="javascript:d=document;t=d.selection?(d.selection.type!='None'?d.selection.createRange().text:''):(d.getSelection?d.getSelection():'');void(wozhai=window.open('http://www.wozhai.com/wozhai/Cento.asp#t='+escape(d.title)+'&u='+escape(d.location.href)+'&c='+escape(t),'wozhai','scrollbars=no,width=475,height=575,left=75,top=20,status=no,resizable=yes'));wozhai.focus();"><img height="16" alt="我摘" src="http://www.extjs.org.cn/misc/digest/wozhai.gif" width="16" border="0">我摘</A> <a href="javascript:d=document;t=d.selection?(d.selection.type!='None'?d.selection.createRange().text:''):(d.getSelection?d.getSelection():'');void(keyit=window.open('http://www.365key.com/storeit.aspx?t='+escape(d.title)+'&u='+escape(d.location.href)+'&c='+escape(t),'keyit','scrollbars=no,width=475,height=575,left=75,top=20,status=no,resizable=yes'));keyit.focus();"><img height="16" alt="天天网摘" src="http://www.extjs.org.cn/misc/digest/365key.gif" width="16" border="0">天天</A> <a href="javascript:t=document.title;u=location.href;e=document.selection?(document.selection.type!='None'?document.selection.createRange().text:''):(document.getSelection?document.getSelection():'');void(open('http://bookmark.hexun.com/post.aspx?title='+escape(t)+'&url='+escape(u)+'&excerpt='+escape(e),'HexunBookmark','scrollbars=yes,width=700,height=600,left=80,top=80,status=yes,resizable=yes'));"><img height="16" alt="和讯网摘" src="http://www.extjs.org.cn/misc/digest/hexun.gif" width="16" border="0">和讯</A> <a href="javascript:u=location.href;t=document.title;c = '' + (window.getSelection?window.getSelection():document.getSelection?document.getSelection():document.selection.createRange().text);var url='http://cang.baidu.com/do/add?it='+encodeURIComponent(t)+'&iu='+encodeURIComponent(u)+'&dc='+encodeURIComponent(c)+'&fr=ien#nw=1';window.open(url,'_blank','scrollbars=yes,width=700,height=600,left=75,top=20,status=yes,resizable=yes'); void 0"><img height="16" alt="百度搜藏" src="http://www.extjs.org.cn/misc/digest/baidu.gif" width="16" border="0">百度</A> <a href="javascript:d=document;t=d.selection?(d.selection.type!='None'?d.selection.createRange().text:''):(d.getSelection?d.getSelection():'');void(keyit=window.open('http://my.poco.cn/fav/storeIt.php?t='+escape(d.title)+'&u='+escape(d.location.href)+'&c='+escape(t)+'&img=http://www.h-strong.com/blog/logo.gif','keyit','scrollbars=yes,width=500,Height=700,status=yes,resizable=yes'));keyit.focus();"><img height="16" alt="POCO网摘" src="http://www.extjs.org.cn/misc/digest/poco.gif" width="16" border="0">POCO</A> <a href="javascript:location.href='http://del.icio.us/post?&url='+encodeURIComponent(location.href)+'&title='+encodeURIComponent(document.title)"><img height="16" alt="Del.icio.us" src="http://www.extjs.org.cn/misc/digest/delicious.gif" width="16" border="0">Del.icio.us</A> <a href="javascript:location.href='http://www.google.com/bookmarks/mark?op=add&bkmk='+encodeURIComponent(location.href)+'&title='+encodeURIComponent(document.title)"><img height="16" alt="Google书签" src="http://www.extjs.org.cn/misc/digest/google.gif" width="16" border="0">Google</A> <a href="javascript:d=document;t=d.selection?(d.selection.type!='None'?d.selection.createRange().text:''):(d.getSelection?d.getSelection():'');void(live=window.open('https://favorites.live.com/quickadd.aspx?marklet=1&mkt=en-us&url='+escape(d.location.href)+'&title='+escape(d.title)+'&top=1','live','scrollbars=yes,status=yes,resizable=yes'));live.focus();"><img height="16" alt="Windows Live" src="http://www.extjs.org.cn/misc/digest/live.gif" width="16" border="0">Live</A> <a href="javascript:d=document;t=d.selection?(d.selection.type!='None'?d.selection.createRange().text:''):(d.getSelection?d.getSelection():'');void(vivi=window.open('http://myweb.cn.yahoo.com/popadd.html?url='+encodeURIComponent(location.href)+'&title='+encodeURIComponent(document.title),'yahoo','scrollbars=yes,width=700,height=600,left=75,top=20,status=yes,resizable=yes'));vivi.focus();"><img height="16" alt="Yahoo书签" src="http://www.extjs.org.cn/misc/digest/yahoo.jpg" width="16" border="0">Yahoo</A> </div> <?php } ?> </div> |
加入到其他cms也是类似的原理.
写得不错,我也是新做网站的,过学习一下啊,网站今天刚好一个月,总的流量不多,自我感觉还行,就是流量太少了
2009-04-23 4:16 下午