Hi,
I just installed the module and it looks really nice. Only the abbreviated url seems to link to a url that is lacking the language code (e.g. ../article-name instead of ../en/article-name). Could it be I'm doing something wrong?
Thanks, Dirkk

Comments

icecreamyou’s picture

It's entirely possible that this is an issue in the module but I'm probably going to need you to test some things to help me fix it because I don't have access to a multilingual site at the moment. I'll get back to you once I figure out what it is that I need you to test.

icecreamyou’s picture

Assigned: Unassigned » icecreamyou
Status: Active » Postponed (maintainer needs more info)

Okay. Go to a node/add form and switch to PHP input mode. Put the following code in the "body" textarea and click "Preview." The code should run once and display the results. Mess around with the last part and see if you can get the URL you're expecting.

global $base_url, $base_path, $base_root;
echo '$base_url:   '. $base_url .'<br />';
echo '$base_path:  '. $base_path .'<br />';
echo '$base_root:  '. $base_root .'<br />';
echo 'base_path(): '. base_path() .'<br />';

echo '<br />';

echo '$_SERVER["SERVER_NAME"]: '. $_SERVER["SERVER_NAME"] .'<br />';
echo '$_SERVER["REQUEST_URI"]: '. $_SERVER["REQUEST_URI"] .'<br />';
echo '$_GET["q"]:              '. $_GET['q'] .'<br />';

echo '<br />';

//This is what the module currently uses to build the current URL.
//Try to use some of the variables above to see if you can get the result you expect.
echo $base_url . base_path() . $_GET['q'];

I'm a little befuddled by your problem because - although I don't have the resources to attempt to reproduce it - the approach this module is currently using *should* produce the right result. It's possible, though, that one of the modules you're using that allows your site to have different URLs for different language sections is messing with things.

DIRKMJK’s picture

Thanks for your assistance. When I run it as is I get ../node/add/news-story [news story being the content type]
When I replace $_GET['q'] with $_SERVER["REQUEST_URI"] I get ../en/node/add/news-story - so I guess that's good isn't it?

icecreamyou’s picture

After some more research - try this:

global $base_url;
echo $base_url . base_path() . request_uri();
DIRKMJK’s picture

this one returns ..//en/node/add/news-story
(with the double slash immediately after the site name - actually the previous one also returned a double slash, i hadn't noticed - sorry about that. anyway, it seems to point to the proper page regardless of the double slash)

icecreamyou’s picture

Status: Postponed (maintainer needs more info) » Needs review

Okay, I found the "real" way I've been looking for since forever now.

echo url($_GET['q'], array('absolute' => TRUE));

...I'll commit this as soon as it's confirmed that it works.

DIRKMJK’s picture

Status: Needs review » Postponed (maintainer needs more info)

I just tried and it returns the correct url - also without the double slash!

icecreamyou’s picture

Category: support » bug
Status: Postponed (maintainer needs more info) » Fixed

Fixed in dev!

DIRKMJK’s picture

Many thanks, it returns the correct url now!
There is one thing; instead of the icon it now presents the text 'post to twitter'. so if you select icon_text you get 'post to twitter post to twitter'

icecreamyou’s picture

Status: Fixed » Postponed (maintainer needs more info)

Hmm... that must be because the image is not located in a virtual language-specific directory.

The source of the image should look something like this:

http://www.example.com/sites/all/modules/tweet/icon.png

...but I assume yours looks something like this?

http://www.example.com/en/sites/all/modules/tweet/icon.png

That's a pretty easy fix, just replace line 108 in tweet.module with this:

  global $base_url;
  $image = '<img src="'. $base_url . base_path() . check_plain(variable_get('tweet_image', $image_location)) .'" alt="'. $text .'" title="'. $text .'" />';

I will commit this change to dev as soon as it's confirmed to work.

DIRKMJK’s picture

Actually, the image is in
http://www.example.com/modules/tweet/icon.png

Incidentally, I just found that I can get it to work by changing line 108 into

  $image = '<img src="http://www.example.com/modules/tweet/icon.png" alt="'. $text .'" title="'. $text .'" />';


icecreamyou’s picture

Status: Postponed (maintainer needs more info) » Fixed

You should put non-core modules in /sites/all/modules instead of /modules to make upgrades easier. But regardless, obviously I can't ask users to go edit their module file to put in their site URL.

I've committed the change to dev. Please reopen this issue if you continue to have problems.

DIRKMJK’s picture

Many thanks for fixing this!
(And I'll move my non-core modules...)

Status: Fixed » Closed (fixed)

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