ShareThis Forums » Publishers

Multiple share this on one page

(6 posts)
  • Started 4 months ago by snewe
  • Latest reply from ShareThisSupport

  1. snewe
    Member

    I had a STAPI-customized button working on my site, but once I added a second one, only the first one works. Is there a limit on the number of calls to the button creation script? When I remove one or the other, the remaining works as required. Thanks!

    Posted 4 months ago #
  2. Hello,

    Insert the code you've acquired from the publisher configuration tool into the <head> of the document and use SHARETHIS.addEntry call to generate ShareThis buttons. For more information on the ShareThis API see http://sharethis.com/publisher/type=stapi and http://support.sharethis.com/developers

    Posted 4 months ago #
  3. snewe
    Member

    I already did that. The JS is in the header and this code is on the page twice:

    <script language="javascript" type="text/javascript">
    //Create your sharelet with desired properties and set button element to false
    var object = SHARETHIS.addEntry({
    title:'Reclaiming the American Right',
    icon: 'http://antiwar.com/antiwar_logo.gif',
    url: 'http://antiwar.com/justin//?articleid=12929'
    },
    {button:false});
    //Output your customized button
    document.write('<span id="share"> Email this</span>');
    //Tie customized button to ShareThis button functionality.
    var element = document.getElementById("share");
    object.attachButton(element);
    </script>
    This only works once on a page.

    Posted 4 months ago #
  4. Ah, my mistake. I misunderstood the problem. You should be able to reuse part of this script, but you'd need to create a new object for each button that will have different shareable content. Eg.
    <script language="javascript" type="text/javascript">
    var object2 = SHARETHIS.addEntry({
    title:'New Title',
    icon: 'New Icon',
    url: 'New URL'
    },
    {button:false});
    document.write('span id="share2">Email this</span>');
    var element2 = document.getElementByID("share2");
    object2.attachButton(element2);
    </script>

    Posted 4 months ago #
  5. snewe
    Member

    Awesome, worked. I had tried adding "2" to all the objects/vars, but didn't do so for the 'span' id. You should add this issue to your FAQ. Thanks for the help!

    Posted 4 months ago #
  6. Will do and glad you got it to work. =)

    Posted 4 months ago #

RSS feed for this topic

Reply

You must log in to post.