[Zope-CMF] CMF base tag rant

Alexander Limi limi at plone.org
Wed Mar 3 05:54:06 EST 2004


OK, guys - minor rant upcoming. Sometimes pain needs to be shared, OK? :]

Yesterday I tried to implement something known as a "skip" link for  
accessibility reasons. The rationale behind this is that at the top of  
every page, there should be a "skip to content" link for blind people and  
systems like mobile phones etc, so they don't have to read all the  
navigation and logo stuff before they get to the content.

The process is really simple:

- Add an <a name="someContent" /> tag right before the content

- Make sure there is a link at the top of your page pointing to  
currentpage.html#someContent.

Easy, right? Wrong.

I load the front page of my CMF/Plone site. Base tag looks like this when  
rendered:

<base href="http://localhost:8080/Plone/index_html" />

Only problem is, my *real* URL is http://localhost:8080/Plone - without  
the index_html in there. Thus, I'm in for a world of pain.

If I make a tag with a link href="#someContent", the page will reload,  
since it thinks that index_html#someContent is what I'm linking to.

Some tinkering later, I try to do the following:

tal:attributes="href string:${request/URL0}#someContent"

But guess what? This won't work either.

I investigate the options i have, noting that no variable seems to keep  
the actual URL that is *inside the fecking URL bar* in my browser.

I turn to Simon Eisenmann for help, he comes up with an idea of using a  
combination of SERVER_URL and PATH_TRANSLATED to construct the actual URL  
we're at.

But guess what? This doesn't work in Virtual Hosting scenarioes. So we  
have to create an additional rule that gets rendered if you have a Virtual  
Hosted system.

The rule ends up looking like this:

<a
  tal:define="url  
request/VIRTUAL_URL|string:${request/SERVER_URL}${request/PATH_TRANSLATED}"
  tal:attributes="href string:${url}#someContent"
> Skip to content</a>

Easy, right?

When it could have been (and is, in the rest of the world) as simple as  
this:

<a href="#someContent">Skip to content</a>

And people wonder if it's "hard to keep compatibility with the CMF". Heh.

Is this stuff scheduled for a cleanup in 1.5? Setting (and don't let me go  
into *depending*) on the base tag being set to something that is not the  
current URL is *evil*.

-- 
__________________________________________________________________

  Alexander Limi   ·   Interaction Architect   ·   Plone Solutions

  Development · Training · Support · http://www.plonesolutions.com
__________________________________________________________________

  Plone Co-Founder   ·   http://plone.org   ·   Connecting Content

 



More information about the Zope-CMF mailing list