We have moved!

Please visit our new Help Center at justgiving-charitysupport.zendesk.com

Adding widgets & buttons to a Drupal website

Whilst we will always endeavour to supply you with simple snippets of code that are easy to embed, adding content to third party websites can often involve bespoke steps as mandated by the content management system in question. 

The first thing to note is that a secure Drupal installation will generally not allow Javascript to be added via the user interface, therefore this will always require some development work. This development work could be repeated on each instance, embedding the code into a block template.


How to add a widget to a block

  • Create a normal block (not a Super block!), and don't type anything other than spaces into the Body field.
  • Write down the block's ID number, which will show in the URL after you save the block and go back to that block's "Configure" page. For example, in the URL http://example.gatech.edu/admin/structure/block/manage/block/30/configure, the block id is the number between "block" and "configure", in this case, 30.
  • Add this block to a page on your site, preferably a test page that no one will find, and keep that page open in your web browser.
  • In the subtheme for your site, usually within its "templates" folder, create a "tipple fip" file that will only effect this specific block, named: block--block--30.tpl.php
  • Inside the block--block--30.tpl.php file, first paste the code for a generic block template file (Drupal 7) from the "View Source" section on this page: https://api.drupal.org/api/drupal/modules!block!block.tpl.php/7 (Abbreviated source example copied below).
  • If you want to completely overwrite what people might type into the Body field of this block, then replace the <?php print $content ?> line, otherwise, decide if your embed code should appear below or above whatever the Body field's content.



Was this article helpful?
0 out of 0 found this helpful