Hi all,

in a multilingual site, the page URL is written without the lang prefix in the url, so I have:

st_url="mysite/my-eng-page"
st_url="mysite/my-ita-page"

instead of

st_url="mysite/en/my-eng-page"
st_url="mysite/it/my-ita-page"

This cause wrong sharing.

Can you please resolve this issue? Is CRITICAL for everyone using multilingual websites!

Thank you very much!

CommentFileSizeAuthor
#4 1801970.patch781 bytesRobLoach
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

MXT’s picture

I think this happen because you build the path in this way in your module:

$mPath = $base_url . $path_module;

where $path_module = '/' . drupal_lookup_path('alias',"node/" . $node->nid);

but neither $base_url nor drupal_lookup_path returns language prefix.

using request_uri() instead, things works well:

$mPath = $base_url . request_uri();

but I'm not a programmer, so I cant give a definitive solution or a patch

djschoone’s picture

I would like to propose this fix. It uses the url() so no need to check if the pathauto module exists also, because url() does this for you. And ofcourse this function does link correct to the language prefix for the selected language.

I will commit if anyone can confirm it works!

Tested on 7.x-2.5 (==HEAD below)

--- HEAD
+++ Modified In Working Tree
@@ -307,17 +307,12 @@
     $path_module = $node->path;
   }
   else {
-    $path_module = "/node/" . $node->nid;
+    $path_module = "node/" . $node->nid;
   }
 
-  // Pathauto integration !
-  if (module_exists('pathauto')) {
-    $path_module = '/' . drupal_lookup_path('alias',"node/" . $node->nid);
-  }
-
   global $base_url;
   // Get the full path to insert into the Share Buttons.
-  $mPath = $base_url . $path_module;
+  $mPath = url($path_module, array('absolute'=>TRUE));
   $mTitle = $node->title;
   
   // Only display the ShareThis buttons if this node fits all the requirements
MXT’s picture

I've tried it: yes seems to works correctly: thank you!

RobLoach’s picture

Status: Active » Needs review
FileSize
781 bytes
RobLoach’s picture

Issue summary: View changes

little mistake...

yaelsho’s picture

Issue summary: View changes

Hello,
I just tested it and its working.
Is there any concern in committing it?
Thanks, Yael

ckhalilo’s picture

Not the same problem but in same category mutli-lang $node->path becomes array, so we have to check if path is array.

Notice : Array to string conversion in sharethis_node_view() (ligne 320 in .../drupal/sites/all/modules/custom/sharethis/sharethis.module).

I fixed issue by Modifiying this.

Line 307 :

- $path_module = $node->path;
+ $path_module = (is_array($node->path))?$node->path["source"]:$node->path;

Note that module pathauto is not active.

purushotam.rai’s picture

This issue probably has been fixed now on 7.x-2.x-dev branch.

purushotam.rai’s picture

Marking this issue as fixed. Thanks a lot for all your inputs. We really appreciate your efforts towards this issue. Feel free to re-open if issue persists.

Thanks

purushotam.rai’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

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