Dear people from sharthis module,

First of all, I love your module. However, there is 1 minor point that needs to be fixed. If i put the share this links, on my front page, in a block, it doesn;t share the base url (example.com) but the more extended url (example.com/node). This is not as it should be. Could you make it so that it only shares example.com, when on front page?

I have now done this dirty by changing the sharethis_block_contents() :

function sharethis_block_contents() {
  if (variable_get('sharethis_location', 'content') == 'block') {
    // First get all of the options for the sharethis widget from the database:
    $data_options = sharethis_get_options_array();
    $path = isset($_GET['q']) ? $_GET['q'] : '<front>';
    if ($path == "node") $path = "<front>"; // but this only works when front page is node...
    $mPath = url($path, array('absolute' => TRUE));
    $mTitle = drupal_get_title();
    //watchdog("debug", "<pre>data_options:".print_r($data_options, true)."path:".$path.print_r($mPath, true)."title".print_r($mTitle, true)."</pre>");
    return sharethis_get_button_HTML($data_options, $mPath, $mTitle);
  }
}
CommentFileSizeAuthor
#3 sharethis-frontpage-1536630-3.patch738 bytescodesmith
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

smitty’s picture

Component: Miscellaneous » Code
Category: feature » bug

For detecting whether it's the frontpage or not we can take the variable site_frontpage. So change the line 7 in the above snippet to:

if ($path == variable_get('site_frontpage')) $path = "<front>";
codesmith’s picture

Version: 7.x-2.3 » 7.x-2.x-dev

This is still an issue - updating to dev.

codesmith’s picture

Status: Active » Needs review
FileSize
738 bytes

Here's a patch to fix the issue.

Gaofengzzz’s picture

Thank you, @GBurg and @codesmith. This patch is tested and commited in 9b6fa48.

Gaofengzzz’s picture

Status: Needs review » Fixed

Change ticket status.

Status: Fixed » Closed (fixed)

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