Hi, I have the following situation: The front page has a ShareThis block in the sidebar to share the entire site. The individual articles would like to have a ShareThis section at the end of the article. above the comments. So it seems I need two ShareThis's. Is there a way to do this? It would be great if we could support multiple ShareThis blocks AND allow it to be in a content type too.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

xenophyle’s picture

Version: 7.x-2.5 » 7.x-2.x-dev
Status: Active » Needs review
FileSize
3.94 KB

Here is a patch that will allow choosing multiple options for Location.

I wasn't sure how to best do this in the code, so you will need to delete the sharethis_location value in the {variable} table manually before the patch will work.

mcfilms’s picture

Thank you xenophyle. I'll try and review this, although I came up with a work-around for the site in question. In any case, this will be a great feature and I think other module users will appreciate it in the future.

SocialNicheGuru’s picture

Issue summary: View changes

no longer applies to latest module 2.6

ubermichael’s picture

FileSize
2.6 KB

Here's a patch against 7.x-2.10 that applies cleanly. It requires that someone delete the sharethis_location variable before it works.

ubermichael’s picture

FileSize
4.37 KB

The previous patch was dumb and should be withdrawn. This one fixes a few more things, like checking for array keys and their values. It also makes the Share This stuff show up on the Manage Display screens.

daddison’s picture

FileSize
3.62 KB

Hey ubermichael, the second version of your patch has some formatting issues (at least the one I just downloaded did). I cleaned it up and applied it to version 7.x-2.12 and it works. I didn't even need to delete the variable. Thanks!

Status: Needs review » Needs work

The last submitted patch, 6: sharethis-2050875-3.patch, failed testing.

ryan.gibson’s picture

Version: 7.x-2.x-dev » 7.x-2.12
Category: Support request » Feature request
Status: Needs work » Needs review
FileSize
5.13 KB

Thanks for the patch, I've rerolled it to work with 7.x-2.12.

To the maintainers, is there a reason this can't be merged? It's gotta be a pretty common need to have share links on content but also in blocks.

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've added this as a feature request for our team to review!

Best
ShareThis Support

mikemccaffrey’s picture

Hmmm... from what I can tell, the most recent patch doesn't work, and I'm not sure how it would work as submitted. Even though the sharethis_location variable is being turned from a string into an array at the start of the config form function, the corresponding field has been left as radio buttons where only one of the three choices can be selected. And due to the mismatch, it doesn't seem like any can be successfully selected after the patch is applied.

However, that issue is a bit moot, since it seems like the settings of where the widget is displayed can be almost completely removed, and the module can simply provide both a block and a field display for every content type by default. And then if the site builder wants to show the widget on a page, they can either place the block into a region or enable the field in a display mode, or they can just leave them as disabled if they are not wanted.

It seems like the only useful location setting on this form is the choice of which content types and view modes you'd like to display the widget inside of the node links, but even this would arguably be better situated on the individual entity type configuration forms.

Make sense?

mikemccaffrey’s picture

Well, I found a good reason not to just provide ShareThis as an extra field in the display settings for every node type: by default every extra field you define starts off as visible on every display mode of every content type. So we should keep the option for which content types to provide the extra field for, unless we want to write an update function that turns off the extra field by default on all existing content types: http://drupal.stackexchange.com/questions/6404/hook-field-extra-fields-h...

However, there still doesn't seem any reason not to provide a block, even if one of the content display choices is enabled. Attached is a patch that removes the check on whether or not to provide the block, and also rephrases the choice on the settings form to "Block only", so it is at least a bit clear that block is still provided if you select one of the other options.

Status: Needs review » Needs work

The last submitted patch, 11: sharethis-2050875-11-show-in-block-and-content.patch, failed testing.

sandip27’s picture

Assigned: Unassigned » sandip27
Status: Needs work » Needs review
FileSize
9.98 KB

Hi, The patch provided by ryanissamson was a bit outdated hence, please find the updated patch for Implementing ShareThis For Block as well as Node at same time.

Thanks

sandip27’s picture

To the maintainers, would be really glad if you could review and merge patch @ #13 and make it available as its very common need.

harivenuv’s picture

Status: Needs review » Reviewed & tested by the community
FileSize
9.93 KB

Hi,

Thank you for the patch and it's working fine. I have cleared the coding standard issues and attaching the patch here.

sandip27’s picture

@harivenu_zyxware, Thanks for the review. Well, when I created a patch, I didn't expected to check for the existing coding standard errors which I think now, I have to. Anyways, thanks again for the review.

I have tried applying revised patch was getting error as "fatal: patch fragment without header at line 196: @@ -280,8 +285,8 @@ function sharethis_get_options_array() {" hence I have created a new patch with you suggestions as well in it.

@gaofengzzz, Please merge the patch sharethis-ShareThis_in_block_AND_on_node-2050875-16-7.x-2.x.patch so that we would be able to see the feature in action !

Thanks

sandip27’s picture

@gaofengzzz, any word on merging the patch ?

naveenvalecha’s picture

Version: 7.x-2.12 » 7.x-2.x-dev
Status: Reviewed & tested by the community » Needs work
Issue tags: +Needs reroll

Thanks for the patch. It needs reroll as will not apply after the changes to the code.

sandip27’s picture

Status: Needs work » Needs review
FileSize
6.78 KB

@naveenvalecha, Please find attached the re-rolled patch. I have checked on my local setup and cleanly applied this patch, so seems we are good to go.

Thanks and let me know if any further issues.

sandip27’s picture

Issue tags: -Needs reroll
naveenvalecha’s picture

Status: Needs review » Needs work
Issue tags: +Needs reroll

Patch does not apply anymore.
Checking patch sharethis.admin.inc...
error: while searching for:

$form['context']['sharethis_location'] = array(
'#title' => t('Location'),
'#type' => 'radios',
'#options' => array(
'content' => t('Node content'),
'block' => t('Block'),

error: patch failed: sharethis.admin.inc:175
error: sharethis.admin.inc: patch does not apply
Checking patch sharethis.module...
Hunk #1 succeeded at 104 (offset -2 lines).
Hunk #2 succeeded at 164 (offset -2 lines).
Hunk #3 succeeded at 471 (offset -2 lines).

naveenvalecha’s picture

Issue tags: +Novice
sandip27’s picture

Hello @naveenvalecha, you sure you are applying the patch to branch 7.x-2.x ? Cause that's what I am doing, since branch 7.x-2.x is the current branch and its applying cleanly. I also tried applying it on couple of more branches on different PC's and working fine on every one of them.

Please check or let me know if what I need to do further to cure it.

Thanks and appreciate your response.

naveenvalecha’s picture

you sure you are applying the patch to branch 7.x-2.x ?

yes. have you done the git pull before applying the patch ?

you can reproduce this by following these steps :

  1. git clone --branch 7.x-2.x https://git.drupal.org/project/sharethis.git
      cd sharethis
  2. git apply -v https://www.drupal.org/files/issues/sharethis-ShareThis_in_a_block_AND_on_nodes-2050875-19-7.x-2.x.patch
sandip27’s picture

Status: Needs work » Needs review
Issue tags: -Needs reroll
FileSize
6.71 KB

Check the attached revised patch.

Thanks

sandip27’s picture

Assigned: sandip27 » Unassigned
sandip27’s picture

Hello @naveenvalecha, any word about this patch review ? Just wondering if we are good to go with this patch or how ?

Thanks

naveenvalecha’s picture

Assigned: Unassigned » purushotam.rai

Assigning to purushotam to do the needful

Pallavi Gupta’s picture

How to display Sharethis buttons for a content type for which a custom tpl file is made? Even if in Manage Display tab Sharethis is set to be visible mode, then too I think my custom tpl file is overwriting it and hence I am not getting share this icons on my content page.

sandip27’s picture

Hello @purushotam.rai,

It's been 4 months, any updates on merging this patch ?

Thanks

yogeshmpawar’s picture

yogeshmpawar’s picture

Assigned: yogeshmpawar » Unassigned
FileSize
6.18 KB

I have added few changes using last patch by @sandip27, now this patch working for me.

navneet0693’s picture

Status: Needs review » Needs work
FileSize
27.24 KB
+++ b/sharethis.module
@@ -148,7 +144,8 @@ function sharethis_node_view($node, $view_mode, $langcode) {
+  if (in_array('content', $location) && $location['content'] === 'content') {

This throws an undefined index error. As it $location[0] = 'content'; (Refer to screenshot) This observation is only made on first install of module. After first install $location will have only 1 index. After you goto configurations and click Save Configurations without any changes, $location will have 3 indexes.

yogeshmpawar’s picture

Status: Needs work » Needs review
FileSize
626 bytes
6.14 KB

@navneet0693 - made changes as per your comment #33.
Please review the updated patch with interdiff.

navneet0693’s picture

Status: Needs review » Needs work
+++ b/sharethis.module
@@ -145,7 +145,7 @@ function sharethis_field_extra_fields() {
+  if (in_array('content', $location)) {

Check is necessary, as $location['content'] will be present but its value may be blank, or not set to 'content'. We will have to figure another way to it.

yogeshmpawar’s picture

Status: Needs work » Needs review
FileSize
1.88 KB
6.13 KB

@navneet0693 - made changes as per your comment #35.
Please review the updated patch with interdiff.

navneet0693’s picture

Status: Needs review » Needs work
+++ b/sharethis.admin.inc
@@ -41,6 +41,13 @@ function sharethis_configuration_form($form, &$form_state) {
+  $location_places = variable_get('sharethis_location', 'content');

+++ b/sharethis.module
@@ -82,63 +82,59 @@ function sharethis_node_view($node, $view_mode, $langcode) {
+  $location = variable_get('sharethis_location', array('content'));

@@ -148,7 +144,8 @@ function sharethis_node_view($node, $view_mode, $langcode) {
+  $location = variable_get('sharethis_location', array('content'));

@@ -454,7 +451,8 @@ function sharethis_block_view($delta = '') {
+  $location = variable_get('sharethis_location', array('content'));

The default value should be array of content => content. Also, the default #state behaviour isn't working for any options.

yogeshmpawar’s picture

Status: Needs work » Needs review
FileSize
3.69 KB
7.56 KB

@navneet0693 - changes done as per your comment #37. changing status to Needs Review again.

navneet0693’s picture

Status: Needs review » Reviewed & tested by the community

Working as per expectations.

gg24’s picture

I have re-tested the patch. It works fine for me.

purushotam.rai’s picture

Status: Reviewed & tested by the community » Patch (to be ported)
naveenvalecha’s picture

Why Patch (to be ported) ?

purushotam.rai’s picture

Status: Patch (to be ported) » Reviewed & tested by the community

purushotam.rai’s picture

Status: Reviewed & tested by the community » Fixed

Patch #38 is working fine. Thanks for all your efforts. Pushing code to 7.x-2.x branch

Status: Fixed » Closed (fixed)

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

vinmassaro’s picture

danjr98’s picture

Hi
I have installed Drupal 8 with the ShareThis.
The ShareThis is being added to CONTENT block
I was expecting that it would share the "content" of the page or article but rather it is sharing the whole page (node i guess)
I have read the above but not sure what i have done wrong.

I really like this widget.

Thanks for any feedback

Chris Charlton’s picture

FYI, just pointed out a small issue with sites also running Domain Access. Solution provided here: https://www.drupal.org/node/2846151#comment-11937569