Not an urgent request but one which would really make this block infinitely more useful.

Would it be possible to build a feature in that allows for a user to make multiple styles of blocks with different icon sets etc. My use case is I would like to be able to use share this in multiple places over a website but also be able to create multiple share this blocks that have different icon sets as well as which networks are displayed.

For example I might want to put only 3 networks on a particular landing page but have more available in a blogging or article section. Or be able to use smaller icons at the top of a post and larger ones with counters at the bottom.

This would allow a user to hide or show blocks for mobile/responsive displays or display a different set of share this icons at the top of a node or at the bottom.

Comments

ahillio’s picture

Issue summary: View changes
<span class='st_facebook_large' displayText='Facebook'></span>
<span class='st_twitter_large' displayText='Tweet'></span>
<span class='st_googleplus_large' displayText=GooglePlus></span>
<span class='st_linkedin_large' displayText='LinkedIn'></span>
<span class='st_sharethis_large' displayText='ShareThis'></span>
<span class='st_email_large' displayText='Email'></span>

Put that in a block and you'll get a share button for each of those.
I'm assuming all of those have to be enabled in the Sharethis config area, but maybe not.
It might be necessary to also have the block provided by ShareThis module on that page (to inherit its' javascript?).

amaisano’s picture

I ran into a similar case and decided it'd be easiest to alter the share this variables when shown in a view. A views block can be created to suite many different situations so I thought that was more flexible.

As the notes in this code indicate, I will eventually expose these options in the Views config UI, and move it to a custom override module.

You can setup a Content-based View that outputs the ShareThis link field, and it will listen to the overridden variables hardcoded in the .inc file below when theming/rendering the links:

<?php

/**
 * @file
 * Field handler to display ShareThis links.
 */

/**
 * Field handler for ShareThis.
 */
class sharethis_handler_field_link extends views_handler_field_entity {

  function render($values) {
    if ($entity = $this->get_value($values)) {
      return $this->render_sharethis_link($entity);
    }
  }

  function render_sharethis_link($entity) {
    $path = url('node/' . $entity->nid, array('absolute' => TRUE));

    /**
     * @todo
     * The line below requires theming of the sharethis button HTML as described
     * in http://drupal.org/node/1335836 . Once the theming issue is resolved,
     * this line can be uncommented/modified to implement that functionality.
     */
     
    $altered_options = sharethis_get_options_array();
    
    /* TODO: Create a custom module that extends this field handler instead of hacking module! */
    /* TODO: Make these adjustable in views UI */
    $altered_options['buttons'] = 'stbc';
    $altered_options['services'] = '"Facebook:facebook","Tweet:twitter","Email:email"';
    $altered_options['option_extras'] = array();
    
    return theme('sharethis', array(
      'data_options' => $altered_options,
      'm_title' => $entity->title,
      'm_path' => $path,
    ));

  }
}
amaisano’s picture

Here's a patch with the same code:

ShareThis Support’s picture

Hi There,

Thanks for your patience here! We've made some changes in our support organization and we're working through responding to these. We appreciate you posting the patch, and please don't hesitate to let us know if you have any additional questions.

Best
ShareThis Support

avpaderno’s picture

Title: Multiple Share this block styles » Multiple "Share this" block styles
Version: 7.x-2.5 » 7.x-2.x-dev