Skip to main content

How to add flattr buttons to your Drupal site

Here is a quick and diry way for putting dynamic flattr buttons in articles on a Drupal site.

The difficult part is getting the javascript thing in the <head> section of your pages. I did it as follows:

I created a file 'flattr.js', with the following content:

(function() {
    var s = document.createElement('script'), t = document.getElementsByTagName('script')[0];
    s.type = 'text/javascript';
    s.async = true;
    s.src = '';
    t.parentNode.insertBefore(s, t);

Then I added the following php code to a block that is visible on every page of the site:


(You might use an existing block, or create a new block just for this purpose.) Make sure you choose 'php' as input format for the block.

Now you just have to paste the code for the button in the articles, on the place where it is needed. You need to specify full html as input format though.

I know there exists a Drupal module for Flattr, but I think it is not ready for easy usage yet.


Comments powered by Disqus