It would be nice if _addtoany_create_button() would allow me to override the css class of the link and potentially other variables.

On top of this it would be nice if addtoany_handler_field_addtoany_link::render() could pass in a css class from views.

Comments

mstrelan’s picture

Example code

addtoany_handler_field_addtoany_link.inc

  function render($values) {
    $node = new stdClass();
    $node->nid = $values->{$this->aliases['nid']};
    $node->title = $values->{$this->aliases['title']};
    $class = isset($this->options['element_class']) ? $this->options['element_class'] : '';
    return _addtoany_create_button($node, FALSE, $class);
  }

addtoany.module

function _addtoany_create_button($node=NULL, $teaser = FALSE, $link_class = '') {
 // some code removed
  $button_innerHTML = ($button_setting == "text") ? $button_text : sprintf('<img src="%s"%s%s %s/>%s',
    $button_image,
    $button_width,
    $button_height,
    filter_xss(variable_get('addtoany_image_attributes', 'alt="Share this"'), array()),
    $button_text
  );

  $classes = array();
  if ($link_class) {
    $classes[] = $link_class;
  }
  if (!$disable_dropdown) {
    $classes[] = 'da2a_button';
  }
	
  return ( sprintf('
    <a%s href="http://www.addtoany.com/share_save" id="da2a_%s">%s</a>
    %s
    ',
    empty($classes) ? '' : ' class="' . implode(' ', $classes) .'"',
    $_addtoany_counter,
    $button_innerHTML,
    $javascript
  ));