, Technology, WordPress

Social Bookmarks: Hide and Seek

UPDATE: – With the new site design and the lack of usage of the links, I decided to take them off. No complaints thus far! This modification still works if you would like to use it.

I was the butt of some joking going on over at Nektros. The entry was all about why you should get rid of all of those one-click social bookmarking links on your site. I’ve had a few other folks comment on them as well… someone told me I only had 25 [sarc].

I didn’t want to take them off… I kind of like them. I’m not sure why exactly, but I do. Besides making it easy to bookmark my page, I also want folks to see all the sites out there that help bookmark. There’s a ton of them! I’m sure, sooner or later, the good ones will rise to the top and the others will die off, but I don’t want to pressure anyone to use one or the other.

So… I did what any good hacker would do. I hacked the Sociable plugin and added some JavaScript that toggles the buttons on or off. It took 3 changes:

  1. Edit the Sociable Plugin to add the link to click on and off… note the bottom line hasn’t changed… that’s just to show you where to put the code in:
    <?php $post = $wp_query->post;
    $html .= '<ul><li><a class="link" title="Display all of the Social Bookmarking options." onClick="showdiv(\'bookmark_'.$postid.'\');">Social Bookmarking</a></li></ul>';
    $html .= '>div id="bookmark_'.$postid.'" class="sociable" style="display:none"><span class="sociable_tagline">';
    $html .= get_option("sociable_tagline"); ?>
  2. Edit the Sociable.css file to set add a hand/pointer cursor… because it’s simply an onclick event and not really a link:
    .link {
    cursor: hand;
    cursor: pointer;
    }
  3. Edit your theme’s header file to put the generic function in to toggle the div on and off:
    <script language="javascript">
    function showdiv(name){
    var obj = (document.getElementById)? document.getElementById(name) : eval("document.all[name]");
    if (obj.style.display=="none"){
    obj.style.display="";
    }else{
    obj.style.display="none";
    }
    }
    </script>

So, clicking the Social Bookmarking link will toggle the content on and off for the specific post!

Download a Sponsored Marketing Whitepaper:
Email Deliverability: Why it Matters, What You Can Do to Improve it

Email Deliverability: Why it Matters, What You Can Do to Improve it

Did you know that only one in five emails actually make it to the inbox? Where do yours end up? Download Now

4 Comments

  1. 1
  2. 2
  3. 3

    Yes, please do! I wanted to make use of this but think I did something wrong (though as ever with technology, not necessarily so) – I backed up the original, thankfully, because when I tried to implement the changes my blog broke – blank screen, no access to admin. A plugin variant would be so much less scary for those of us without the ability to do such cool things with confidence! 🙂 x

  4. 4

This site uses Akismet to reduce spam. Learn how your comment data is processed.