[drupal-devel] [bug] Handle full URLs in url() and l()

killes drupal-devel at drupal.org
Thu May 12 15:00:15 UTC 2005


Issue status update for http://drupal.org/node/10888

 Project:      Drupal
 Version:      cvs
 Component:    base system
 Category:     bug reports
 Priority:     normal
 Assigned to:  Anonymous
 Reported by:  jhriggs
 Updated by:   killes at www.drop.org
 Status:       patch

I had benchmarked /node as anon user without cache.




killes at www.drop.org



Previous comments:
------------------------------------------------------------------------

September 16, 2004 - 17:01 : jhriggs

Attachment: http://drupal.org/files/issues/full_url.patch (1.97 KB)

This little patch allows full URLs to be used for the url() and l()
functions, giving modules a single interface for creating links. 
Currently, modules must use l() for drupal links and raw HTML for
external links.  This patch changes url() to handle -- basically pass
through -- full URLs while still doing the proper handling of internal
paths and works with clean URLs enabled or disabled.  It also shortens
(and hopefully simplifies) the url() code a bit.


Some examples of calls that now work:



<?php
l('a link', 'some/path');  // same as before
l('an external link', 'http://drupal.org/');
l('full with query', 'http://google.com/search?q=define:foo');
l('full with separate query', 'http://google.com/search', array(),
'q=define:foo'); // same link as above
l('full with fragment', 'http://drupal.org/node/5942#comment-12374');
l('full with separate fragment', 'http://drupal.org/node/5942',
array(), NULL, 'comment-12374'); // same link as above
?>






------------------------------------------------------------------------

September 30, 2004 - 13:09 : moshe weitzman

+1. less HTML in code is a good thing for readability, if nothing else.




------------------------------------------------------------------------

January 24, 2005 - 22:06 : mathias

Attachment: http://drupal.org/files/issues/external_urls.patch (838 bytes)

Revisiting this issue one year later shows we're almost there. The only
thing that's left is the ability to handle external urls when
clean_urls is disabled.  Once implemented, menu.module can happily
accept external urls and not just Drupal paths, making the menu system
much more attractive to end users.


I'll update the menu.module docs if this patch (or an alternative
solution) is accepted.




------------------------------------------------------------------------

March 14, 2005 - 00:36 : killes at www.drop.org

Attachment: http://drupal.org/files/issues/external_urls_0.patch (909 bytes)

Updated from Drupal root directory.




------------------------------------------------------------------------

March 14, 2005 - 02:05 : gordon

+1 This is a good thing for people who can't using clean urls.




------------------------------------------------------------------------

April 2, 2005 - 08:23 : TDobes

This patch seems like a good idea, but does not apply anymore.  Also,
shouldn't the comments for l() and url() be updated to indicate that
the functions will work with both internal and external URL's?




------------------------------------------------------------------------

April 2, 2005 - 09:25 : asimmonds

Attachment: http://drupal.org/files/issues/external_urls_1.patch (897 bytes)

The &'s had been changed to & amp; , here's a valid patch




------------------------------------------------------------------------

May 12, 2005 - 16:57 : adrian

This is a  new patch against cvs that allows url() to create external
links, with the side-effect that menu can now be used to make external
links.
Also closes http://drupal.org/node/10177


This will be even more important with the primary links menu
integration. (This patch already cleans up a special case in
phptemplate for that).


Killes benchmarked this, and it turns out the difference is negligible.
Requests per second:    1.33 [#/sec] (mean) = with patch
Requests per second:    1.31 [#/sec] (mean) = without patch.







More information about the drupal-devel mailing list