Hi,

There is a bug in Drupal 4.6.2 core: it is impossible to create a link with absolute path. There is an 'absolute' parameter in function url but it doesn't work. Even passing TRUE, a base_url is still added at the beggining of the link.

common.inc, function url, line 1500 contains the following code:
$base = ($absolute ? $base_url .'/' : '');
but absolute parameter is ignored:
return $base . $script .'?q='. $path .'&'. $query . $fragment;

I did the following patch only for clean_url = 0:
change
$base = ($absolute ? $base_url .'/' : '');
to
$base = (!$absolute ? $base_url .'/' : '');
$q = (!$absolute ? '?q=' : '');
$script = (!$absolute ? $script : '');
and use $q instead of '?q='.

Please, make necessary changes in the next version of Drupal.
Thank you.

Comments

ardas’s picture

I just want to add that I found this issue when using aggregator2. Full article link is formed as follows:
$links[] = l(t('full article'), $node->link, array(), NULL, NULL, TRUE);

The last TRUE parameter is not working, a full article page is not opened.

Most of my clients prefer to open such links in new windows. This is really more convenient when reading news.
That's why I suggest to include target = _blank in the future releases:
$links[] = l(t('full article'), $node->link, array('target' => '_blank'), NULL, NULL, TRUE);

This is just a proposition :)

Thank you.

ardas’s picture

It is possibly not a good patch, because it may brake logic somewhere.
May be somebody suggests anything else ?

Steven’s picture

The code is right: an absolute URL is a fully qualified one, which starts with the $base_url (i.e. http://drupal.org/node/1).

If you want a relative URL, pass FALSE for $absolute (i.e. node/1).

Read the code you pasted again, it works exactly as I described. And please post an issue next time.

--
If you have a problem, please search before posting a question.

ardas’s picture

It still doesn't work.

aggregator2.module -> function aggregator2_link, line 154:
I tried both:
$links[] = l(t('full article'), $node->link, array('target' => '_blank'), NULL, NULL, TRUE); and
$links[] = l(t('full article'), $node->link, array('target' => '_blank'), NULL, NULL, FALSE);

The result is the same. Both links are as follows:
http://server.com/?q=http://www.rssnews.com/news11111.html
instead of http://www.rssnews.com/news11111.html without http://server.com/?q=

Please check it.