Better URL for skip links

Tonico Strasser <[email protected]> Wed, 23 Jun 2004 17:57:08 +0200
Newsgroups gmane.comp.web.zope.plone.design
Message-ID <[email protected]>
Hello,

the zope-general mailing list seems to be broken, so I'll try to get 
some feeback here on the plone-design list.

It seems to be difficult to generate correct URLs for skip links, as 
seen at test.plone.org. I found this URL in the source of the homepage:

Location:
<http://test.plone.org/search?SearchableText=plone>

Generated URL:
<http://test.plone.org/VirtualHostBase/http/test.plone.org:80/plone.org/VirtualHostRoot/search#documentContent>

Expected URL:
<http://test.plone.org/search?SearchableText=plone#documentContent>

This is the mail I sent to zope-general, it contains a possible solution:

Use case

   I want to add fragement identifier like #xyz to a link and don't want 
to reload the page and preserve the query strings when I click on it.

   Example address: <https://www.example.com/foo/bar?x=y>

Why it doesn't work by default

   By default, if I click on an anchor with '#xyz' a regular UA computes 
https://www.example.com/foo/#xyz because Zope adds a <base>
tag to generated pages.

This little python script might help to get the "real" location, but I'm 
not sure if it will work in all different setups and Zope versions:

     request = context.REQUEST

     server_url = request.get('SERVER_URL')
     path_info = request.environ.get('PATH_INFO')
     path_info = path_info.split('VirtualHostRoot')[-1]
     query_string = request.get('QUERY_STRING')

     if query_string:
         query_string = '?%s' % query_string

     location = server_url + path_info + query_string

     return location

My questions

   Is 'PATH_INFO' always available?

   Is there something else I should consider?

Thanks.

Tonico



-------------------------------------------------------
This SF.Net email sponsored by Black Hat Briefings & Training.
Attend Black Hat Briefings & Training, Las Vegas July 24-29 - 
digital self defense, top technical experts, no vendor pitches, 
unmatched networking opportunities. Visit www.blackhat.com