I have a Drupal 7 site. I'd like to add Social Media follow buttons (i.e. Follow us on Facebook, Twitter, Linkedin). I grabbed some Javascript code from http://www.addthis.com which generates these buttons and also links to some analytics services I will be using. Now I need to figure out how to place the AddThis Javascript code I generated, to a Drupal block. Once it's in a block, it will be easy for me to move around my Drupal site pages.
Why not just use the addthis module rather than adding a block. If you however want to add a block, just go to admin/structure/block click on add block. Paste your script in and select filter type of php code and click save If you do not have PHP filter in the filter type, enable it under the core module | |||||||||||||||||||||
|
I don't have an answer, because I have exactly the same question for HTML, but I can't find another way to react. @4life: unfortunately, the addthis module doesn't exist for Drupal 7 in 'recommanded release' yet. I tried to create a block in the way you explained, but when I select 'Full HTML' and place the block on a certain page, it only displays the code itself, instead of 'reading' the code... How can I fix this? | |||||
|
In order to add Social Media follow buttons you can use the Follow module. If you need to add Social Media share buttons you can use the AddThis module or the Easy Social module. To attach CSS or JS files to a specific block you will need to build a custom module that implements the hook_block_view_alter to manipulate the block render array and then use Drupal 7 FAPI's #attached attribute to attach the file to the block. | |||||||||||||
|