Hi!

I would like to display 5 addthis buttons in a block. I used the block's basic toolbox, but it shows only facebook and twitter. I have set up the enabled services under configuration, tried setting them through addthis UI config at advanced settings addthis_config, rearranged the icons on my addthis account, but neither of these had any affect. With the basic button I have 4 of the wanted services.

Do you have any idea what I did wrong?
Thanks!

CommentFileSizeAuthor
#7 1364848-no-type-fix.patch856 bytesmatglas86

Comments

snoopy77’s picture

I also have the same problem !

matglas86’s picture

Hi guys,

Please see my comment here http://drupal.org/node/1363682#comment-5336398 as it is about the same thing. Try it and I hope it helps. If not let me know.

Bakkon’s picture

Thanks for the quick reply!
I'm just getting familiar with building or modifying modules, so could you help me where do I find the parameters for $options? It took me 2-3 hours only to modify the button size to 32x32, so it would be much faster:)
Thanks

matglas86’s picture

When you look here (addthis_displays/addthis_displays.field.inc) you'll see the code for the two basic display types that there are. Starting on line 12 you will see the setting parameters. The $options parameter will contain the settings that you can alter. Here is the reference to the settings. $options['#display']['settings'].

So you can do for example

function HOOK_addthis_markup_options_alter($options) {
  // To apply this to the block implementation.
  if (isset($options['#block']) && $options['#display']['type'] == 'addthis_basic_toolbox') {
    $options['#display']['settings']['share_services'] = 'twitter, google_plusone';
  }
}

note I did not test this code but it should be almost like this ;)

In this file (addthis_displays/addthis_displays.addthis.inc) you see the rendering of the toolbox and how the options are used.

You can also alter the markup render array like this.

function HOOK_addthis_markup_alter($markup) {
  // Do a print_r() or dpm() here to see what array you have and alter it.
}
frixos12’s picture

Hi matlas

and thank you for your posts.

I have tried the above code but i get a warning message :Undefined index in type.

I removed $options['#display']['type'] == 'addthis_basic_toolbox' condition but nothing really changed.

Have you tested this code yourself?

Thank you.

matglas86’s picture

If you know how to use dpm() from the devel module you could run some debugging yourself. A index that is not available should not be to hard fix. I have not tested the code I typed it out of what I know.

matglas86’s picture

Assigned: Unassigned » matglas86
Category: support » bug
Status: Active » Needs review
StatusFileSize
new856 bytes

I found a issue in the code because type was not added as was supposed to. Therefore here is a fix.

And the alter code is like this.

function HOOK_addthis_markup_options_alter(&$options) {
  // To apply this to the block implementation.
  if (isset($options['#block']) &&
      isset($options['#display']['type']) && $options['#display']['type'] == 'addthis_basic_toolbox')
  {
    $options['#display']['settings']['share_services'] = 'twitter, google_plusone';
  }
}

I hope you can test this patch.

matglas86’s picture

Status: Needs review » Fixed

Patch applied to the master and dev branch for 7.x-4.x

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

waaadim’s picture

hi, i've tried your code snippet but my block still shows only facebook and twitter.

joshicsin’s picture

Here is the solution for 7.x:

1) Open file addthis_displays.field.inc and do following modifications:

$formatters['addthis_basic_toolbox'] = array(
    'label' => t('Basic Toolbox'),
    'field types' => array(AddThis::FIELD_TYPE),
    'settings' => array(
      'share_services' =>  AddThis::getInstance()->getEnabledServices(),//'facebook,twitter',
      'buttons_size' => 'addthis_16x16_style',
      'counter_orientation' => 'horizontal',
      'extra_css' => '',
    ),
  );

2) Open addthis_displays.addthis.inc and do following on line #30

  $services = trim(implode(", ", $options['#display']['settings']['share_services']));
  $services = str_replace(' ', '', $services);
  $services = str_replace('0', '', $services);
  $services = explode(',', $services);

This should fix the issue.

Thank you.

ruthverena75’s picture

hi matglas, thanks for taking care of this issue.
i use the dev branch for 7.x-4.x and i get only facebook and twitter in the block toolbox.
an when i apply the modifications mentioned in #11 i get no more services at all and a warning
Warning: implode() [function.implode]: Invalid arguments passed in addthis_displays_addthis_display_markup__addthis_basic_toolbox() (Zeile 30 von […]/sites/all/modules/addthis/addthis_displays/addthis_displays.addthis.inc).

chris-cmfi’s picture

I get the same error as #12 following this last solution.

ruthverena75’s picture

help? anybody?

ruthverena75’s picture

Status: Closed (fixed) » Active
Bakkon’s picture

Hi!

I hardcoded it in the end, I wouldn't recommend that, because you loose it when you upgrade the module, but it was good for my purposes.

This is for 7.x-4.x-dev. In the addthis/addthis_displays/addthis_displays.field.inc file starting from line 9 you find

$formatters['addthis_basic_toolbox'] = array(
    'label' => t('Basic Toolbox'),
    'field types' => array(AddThis::FIELD_TYPE),
    'settings' => array(
      'share_services' => 'facebook,twitter,linkedin,email,print',
      'buttons_size' => 'addthis_32x32_style',
      'counter_orientation' => 'horizontal',
      'extra_css' => '',
    ),
  );

If you edit the shared_services you can add the one you need.
Once again it would be cleaner with hook_field_formatter_info() but that time i didn't understand a thing about hooks:P
Hope this helps until a more elegant solution is out.

bryancasler’s picture

Priority: Normal » Critical

Same problem with the current dev. Renders the modules unusable.

filnug’s picture

Assigned: matglas86 » filnug

The solution #16 from Bakkon worked for me.
But it s sure this is not the best way to work with this module...

matglas86’s picture

Status: Active » Fixed

Please take a look at my example module here. Or download a example module from github (ZIP).

This example show exactly how to work with this.

For your information I am working on a solution to have the same way of configuration as on the fields to be available on the block page. This is a little more difficult to implement unfortunately.

I hope this example helps you all.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

bharathkumarkn’s picture

Version: 7.x-4.x-dev » 7.x-4.0-alpha1
Component: User interface » Documentation
Assigned: filnug » bharathkumarkn

Even I had the same problem..
I Just configured it in content type "Manage Display" settings. There r 3 display settings under "Manage Display", 1) Default, 2) full content, 3) Teaser.
Configure addthis display and include comma separated list of services for your toolbox in "full content" view not in "default" view. That's all.

It works in 7.x-4.0-alpha1.

knalstaaf’s picture

Status: Closed (fixed) » Active

This is not fixed yet, or is it? (I'm still having the very issue)

g35nightrider’s picture

I'm still having the same issue. But hacked it using #16's solution, which I will lose on Module update. I had to manually fill in the services block in the addthis_dispalys.field.inc. I can't even use this module out of the box.

'settings' => array(
'share_services' => 'stumbleupon,twitter,facebook, pinterest, google_plusone',
'buttons_size' => 'addthis_32x32_style',
'counter_orientation' => 'horizontal',
'extra_css' => '',

jackhutton’s picture

It seems the contentype field 'addthis' is configurable .. I'm able to add various services.
The block 'addthis' only displays twitter & facebook .. It'd be great to have the same configuration options with the block as you do with a display type.

matglas86’s picture

Version: 7.x-4.0-alpha1 » 7.x-4.x-dev
Category: Bug report » Feature request
Issue summary: View changes
Parent issue: » #1694868: Block only uses defaults from Display type Toolbox - can't add services like you can on content type

There was another issue abou the same thing. I created the patch for it. Please review that one.
#1694868: Block only uses defaults from Display type Toolbox - can't add services like you can on content type

matglas86’s picture

Status: Active » Needs review

Review the issue I mentioned in the comment before.

matglas86’s picture

If I don't receive feedback on the issue i mentioned before in the coming week I'm going to apply that patch and close this issue. If you have any feedback please post it in the other issue.

matglas86’s picture

Status: Needs review » Fixed

Fixed. See parent issue.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.