ShareThis button directly in Drupal's tpl.php files

681 views Asked by At

I only need to show custom button for sharing on nodes, but I need to put a different button on a lot of places (block quote, view result, image in node...) and to share just that part (probably with anchor tag suffix in the url). When the user clicks on the button, the modal/popup of ShareThis should be shown.

Is there any way to implement this directly into tpl.php file?

There is an example of the similar implementation of AddThis, something like this I need from ShareThis:

<div class="addthis_sharing_toolbox" data-url="THE URL" data-title="THE TITLE"></div>

It is not necessary for me to use the module, so any idea or possible aproach to this is welcome.

2

There are 2 answers

1
pete80 On BEST ANSWER

Looking at the following link: http://support.sharethis.com/customer/portal/articles/464452-integration-with-a-website you could add the javascript to the html.tpl.php file and the class in the node.tpl.php file or a custom block.

0
MilanG On

You can add any kind of code to template files of course. If it's just for specific content type add it to node template. And if it should be added for all (or many) content types (outer template) add it to page.tpl.php...or most outer if you want to place some content to i.e. page header - html.tpl.php

There you can put some if statement to i.e. display it on every node page except some...