Welcome to Geeklog, Anonymous Friday, March 29 2024 @ 04:56 am EDT

Geeklog Forums

Social bookmarking hack


Status: offline

justrage

Forum User
Newbie
Registered: 06/23/07
Posts: 10
Here is a pretty painless hack to add social bookmarking to your site. I know there is a plugin that does this all ready but this script requires almost nothing extra from your hosting service (if your worried about performance).

I posted this onto hacks plugins but not too sure it it belongs there. If you want to download the file you can get it from http://www.techtricks.org/?p=11

You can see an example on www.justrage.com (top right corner and each story posted).


1) Open your head.thtml file for your theme(s) (/layouts/yourtheme/head.thtml).

2) Search for {menu} or place this where ever you perfer to have it displayed:

Text Formatted Code
<a class="a2a_dd header-navigation" href="http://www.addtoany.com/share_save">Share</a>
<script type="text/javascript">
<!--//
a2a_config = {linkname:'YOUR_SITE_NAME_HERE', linkurl:'http://YOUR_WEBSITE_HERE', onclick: 'true',prioritize:["slashdot", "myspace", "fark", "wordpress", "reddit", "stumbleupon", "google_bookmarks", "friendfeed"]};
//-->
</script>
<script type="text/javascript" src="http://static.addtoany.com/menu/page.js"></script> &nbsp;




3) Save this file and load up your website to confirm the link is working.



4) Next open your storytext.thtml file (located in layout/YOUR_THEME/storytext.thtml) Add the following code where ever you want it disp
Text Formatted Code

<div class="a2a_kit a2a_default_style">
<a class="a2a_dd" href="http://www.addtoany.com/share_save"><img src="http://static.addtoany.com/buttons/share_save_120_16.gif" width="120" height="16" border="0" alt="Share/Bookmark"/></a></div>

<script type="text/javascript">
a2a_config.linkname = '{story_title}';
a2a_config.linkurl = '{article_url}';
a2a.init('page');
</script>
 



5) Save storytext.thtml and load your website to confirm it is displaying correctly. Change position until you find a good position within your site.



How does this all work?

When your page loads the javascript is executed and the first button is generated with the correct links/css. After this first loading of the javascript
the script is now called executed for each article that is displayed. by doing it this way we only have 1 javascript to load and its loaded only once and simply executed as needed!

 Quote

Status: offline

suprsidr

Forum User
Full Member
Registered: 12/29/04
Posts: 555
Location:Champaign, Illinois
Just a FYI - where you have:
Text Formatted Code
linkname:'YOUR_SITE_NAME_HERE', linkurl:'http://YOUR_WEBSITE_HERE'

both site_name and site_url are available in storytext.thtml and featuredstorytext.thtml
so that would be:
Text Formatted Code
linkname:'{site_name}', linkurl:'{site_url}'


Makes it more cookie cutter

Oh and you'd also want this in featuredstorytext.thtml as well.

I applied this to mysite a couple of years ago... I had always meant to share... glad you did Smile

-s

FlashYourWeb and Your Gallery with the E2 XML Media Player for Gallery2 - http://www.flashyourweb.com
 Quote

Status: offline

justrage

Forum User
Newbie
Registered: 06/23/07
Posts: 10
o good point I didn't think to include those. For some reason I really enjoy using full paths. Dont ask me why!
 Quote

All times are EDT. The time is now 04:56 am.

  • Normal Topic
  • Sticky Topic
  • Locked Topic
  • New Post
  • Sticky Topic W/ New Post
  • Locked Topic W/ New Post
  •  View Anonymous Posts
  •  Able to post
  •  Filtered HTML Allowed
  •  Censored Content