ShareThis Forums » Publishers

STAPI Beginner: Creating a custom Icon

(5 posts)

  1. dbarron
    Member

    I am trying to install Sharethis on my Joomla site and STAPI fits the bill, but I am having some problems. I will be using an extension to insert the Sharethis code and have been successful installing Sharethis by following the instructions on this page:

    http://sharethis.com/publisher?type=stapi

    1st I generated the widget code and placed in within the <head> tags.
    2nd I copied the "share Object" code into the site were I wanted the "sharethis" button to be seen.

    Up to this point everything is working. I can see the button and the window pops up for me. However, I also want to create my own sharethis button. All I want is the green "sharethis" button with no text. So I follow the instructions on this page:

    (How to create your own custom button)
    http://support.sharethis.com/developers/developers-faq/stapi/62

    When I set the button to false and add the extra code, the sharethis icon disappears and my custom button does not show up. I was hoping someone could break down the code a bit more. Does anyone have clearer directions and explain what parts are variables (parts I adapt to my site) and what parts are fixed.

    Thank you for any help.

    Posted 6 months ago #
  2. Hello,

    The idea behind creating your own ShareThis object is to instantiate an object of the SHARETHIS.addEntry and bind that object to your own custom HTML button with JavaScript.

    I'd be happy to troubleshoot your code if you post in here, or mail it to feedback@sharethis.com

    We'll get this solved!

    Posted 5 months ago #
  3. dbarron
    Member

    Sorry for the slow reply. I have figured out some things in the meantime and have gotten a bit farther. It had to do with my ' and ". When I corrected the ' and " in the code the custom button was able to render. However, since I am farther than I was before another problem came to the surface. I am using joomla and a plug-in that uses tags that you can insert to dynamically call functions such as your title, url, and description. The code for example looks like this.

    [code]
    <script language="javascript" type="text/javascript">
    //Create your sharelet with desired properties and set button element to false
    var object = SHARETHIS.addEntry({
    title:'***title***',
    url:'***url***',
    summary: '***description***'},
    {button:false});
    //Output your customized button
    document.write('<span id="share"><img src="/images/M_images/share-icon-16x16.png" /></span>');
    //Tie customized button to ShareThis button functionality.
    var element = document.getElementById("share");
    object.attachButton(element);
    </script>
    [/code]

    On a blog layout with multiple sharethis icons, only the first sharethis icon will work, the others on the page will not. When the first sharethis window opens and you click on google for example, it will use a title not even related to the article you are trying to save. However, if you go to a page with just that one article and only one sharethis button, everything works like a charm. So the problem is when you have more than one sharethis button on the page.

    I read this forum posting on multiple sharethis icons.

    http://forums.sharethis.com/topic/multiple-share-this-on-one-page?replies=6

    I am not able to create a new object for each button. The plug-in I am using only allows you to enter the code once and the ***url***, etc customize it according to the content it is attached to. Are there any other solutions to having more than one sharethis icon on one page than having to create a new object for each button. I hope I am making sense.

    Posted 5 months ago #
  4. The problem you're experiencing is due to declaring multiple objects with the same name but different descriptions on the page. This is going to cause errors in the .getElementById function. Each object must have a different name.

    I'm afraid that with our current API, this is the only way to having multiple custom ShareThis buttons on a page.

    Posted 5 months ago #
  5. dbarron
    Member

    Thank you so much for your help and response. That makes perfect sense and I am good with that. I will see if I have other options in sharethis extensions for joomla.

    Posted 5 months ago #

RSS feed for this topic

Reply

You must log in to post.