Welcome to Geeklog Friday, October 20 2017 @ 11:05 pm EDT


Status: offline

justrage

Forum User
Newbie
Registered: 23/06/2007
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:

PHP 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
PHP 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!


Status: offline

suprsidr

Forum User
Full Member
Registered: 29/12/2004
Posts: 555
Location:Champaign, Illinois
Just a FYI - where you have:
PHP 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:
PHP 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

Status: offline

justrage

Forum User
Newbie
Registered: 23/06/2007
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!

All times are EDT. The time is now 11:05 pm.

  • 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