[development] Help with custom_url_rewrite_outboud(), url(), and l() because external URLs need rewriting too

Alex Bronstein alex at craftyspace.com
Tue Nov 10 22:16:55 UTC 2009


The limitation of a completely frozen API once a major version is 
released causes these kinds of frustrations. I'd like to know what 
people think of http://drupal.org/node/535612#comment-2250926. If you 
have thoughts about it, please share them on the issue rather than by 
email. Thanks.

Dave Reid wrote:
> It is already fixed in Drupal as it lives as hook_url_outbound_alter() 
> now, as well as replacing taxonomy_term_path and hook_term_path().
>
> As I explained in the issue that MT posted, the only way to fix this 
> in D5 or D6 is to patch common.inc to move the 
> custom_url_rewrite_outbound up in the execution of ulr(), before the 
> url alias lookups and the return line for external links. However, I 
> doubt this change would ever be approved since it's basically an API 
> change because of when the function is called. This would be like 
> changing hook_nodeapi('update') to be called before a node is updated 
> instead of afterwards.
>
> We just probably have to live with the fact that this was a poorly 
> implemented feature, and at least look forward to things happening 
> correctly now with D7+.
>
> Dave Reid
> dave at davereid.net <mailto:dave at davereid.net>
>
>
> On Mon, Nov 9, 2009 at 4:56 PM, Ken Rickard <agentrickard at gmail.com 
> <mailto:agentrickard at gmail.com>> wrote:
>
>     I think you may need a patch. We had something similar come up in
>     Drupal 5, and obviously missed this use-case when we had the call to
>     custom_url_rewrite_outbound() inserted in the url() function.
>
>     The D5 version of Domain Access shipped with a functional backport of
>     the patch, so best practice suggests fixing this against Drupal 8 (or
>     7 if we can call it an API bug) and then backport the patch to D6.
>
>     /me will vote that this is a bug in the API.
>
>     - Ken Rickard
>     agentrickard
>
>
>     On Mon, Nov 9, 2009 at 11:25 PM, Mlen-Too Wesley
>     <mlen.too.wesley at gmail.com <mailto:mlen.too.wesley at gmail.com>> wrote:
>     > Hello,
>     >
>     > I am currently developing a module to help libraries rewrite
>     links to
>     > external databases, such as ProQuest and LexisNexis, routing
>     those links
>     > through an EZProxy or other proxy referral server.
>     >
>     > For example, consider a resource located at:
>     > http://www.books24x7.com/marc.asp?bookid=30164
>     >
>     > If accessed from an on-campus IP address, the resource will be
>     available to
>     > the student. However, if off-campus, the student would either
>     have to use
>     > VPN to route all their internet traffic through a university IP
>     address or
>     > use an proxy referral server, such as EZProxy.
>     >
>     > EZProxy is easier, so from the library home page, the link is
>     rewritten to
>     > something such as:
>     >
>     http://ezproxy.example-library.edu/login?url=http://www.books24x7.com/marc.asp?bookid=30164
>     >
>     > This way, the student is presented with a login screen for
>     authentication
>     > and then directed to the resource.
>     >
>     > An easy module to make... or so I thought. Given the
>     > custom_url_rewrite_outbound() function, this kind of stuff
>     should be easy to
>     > do in Drupal, but it is not. The url() function in common.inc
>     returns the
>     > $path variable without any attempts to call
>     custom_url_rewrite_outbout().
>     >
>     > All would be well, if line 1408 of common.inc added the same
>     functionality
>     > to external links in the url() function as it does for internal
>     links. It
>     > just needs 3 lines:
>     >
>     >     if (function_exists('custom_url_rewrite_outbound')) {
>     >       // Modules may alter outbound links by reference.
>     >       custom_url_rewrite_outbound($path, $options, $original_path);
>     >     }
>     >
>     > Other than applying a patch, does anyone know another way around
>     this issue?
>     >
>     > I am not talking about Apache mod_rewrite or anything similar,
>     Clean URLs,
>     > or the Path module and URL aliases. I am looking for a way to
>     rewrite
>     > external URLs in anchor tags (links) without creating a wrapper
>     function for
>     > url() or l()... or using JavaScript or AJAX.
>     >
>     > Thanks!
>     >
>     > MT
>     >
>     >
>     >
>     >
>     >
>     >
>
>
>
>     --
>     Ken Rickard
>     agentrickard at gmail.com <mailto:agentrickard at gmail.com>
>     http://ken.therickards.com
>
>



More information about the development mailing list