Share buttons for Drupal
Add the buttons to any content type through a block or a Twig template.
- Ends up
- Below the body field of whichever content types you choose.
01 Load the script from your theme
Declare it as a library in THEME.libraries.yml, then attach it in THEME.info.yml so it loads on every page.
yaml
# THEME.libraries.yml addtosite: js: //static.addtosite.com/widget.js: { type: external, attributes: { async: true } } # THEME.info.yml libraries: - THEME/addtosite02 Put the buttons in the node template
Copy node.html.twig into your theme and add the kit after the content. Twig gives you the canonical URL and title, so each node shares itself rather than the front page.
twig
{{ content }} <div class="ats_kit ats_kit_size_32" data-url="{{ url('entity.node.canonical', {'node': node.id}) }}" data-title="{{ label|render|striptags|trim }}"> <a class="ats_btn_facebook"></a> <a class="ats_btn_x"></a> <a class="ats_btn_linkedin"></a> <a class="ats_btn_email"></a> <a class="ats_dd"></a> </div>03 Or use a block, with no theme edit at all
Structure → Block layout → Add custom block, set the text format to Full HTML, paste the snippet, then place the block in the Content region and limit it to the content types you want.
Another platform
The same buttons, in someone else's editor. All of them are on theplatforms page.
Want a different set of services?
The snippets above use a sensible default. The configurator builds the exact markup for whichever services you want, in whichever order, at whichever size — paste that in place of the kit shown here.