W3C home > Mailing lists > Public > www-html@w3.org > May 2006

linking to a page name derived from current page?

From: Bo Berglund <bo.berglund@telia.com>
Date: Thu, 25 May 2006 04:56:34 +0200
To: www-html@w3.org
Message-ID: <0fc872l226f2nduuj1lud9jdqum6tutrrb@4ax.com>




Hi,
I have a strange question that might not even belong here (if not then
please direct me to the right place):

My website has been translated to Spanish. This has been done by
translating each page and creating a copy with the same name but added
an extra .sp, like this:
index.shtml -> index.sp.shtml

I use SSI so the pages are named .shtml because of this. The reason is
that all pages refer to an included file "contentbar.txt" (and now
also contentbar.sp.txt) that holds all navigational links and displays
as a link list to the right of our pages.

What I would like to do is to put inside this list a link to switch to
the *other* language page with the *same* basic name. So if I am on
somepage.shtml the link would point to somepage.sp.shtml and if I am
on somepage.sp.shtml the link would point to somepage.shtml.
Of course the link on contentbar.txt points to the somepage.sp.shtml
and vice versa.

Now the problem is *how* I can create this link! The contentbar.txt
file is included in *all* of the other page files so the page it is
included on is not known until it is loaded. Basically only the client
browser sees the fully assembled page.

Is there some command I can put into an include file or otherwise that
can let the server or client browser compute the correct destination
file according to these rules:
1) get current page base name: /mysite/somepage.shtml
2) remove the extension(s) and path: somepage
3) add the correct extension: somepage.sp.shtml
4) put this new string into the language switch link:
<A href="somepage.sp.shtml">Spanish version</a>
or
<A href="somepage.shtml">English version</a>

Of course I could put the pageswitch link into the body of each page
file and hardcode the name there because inside the page source I know
the name of the page, but that involves editing about 250 page files
and I don't really want to do this if it can be avoided.

Finally, the website exists on Earthlink on a UNIX server so I guess I
cannot use IIS specific code, it has to be general in nature....

Bo Berglund
Received on Tuesday, 30 May 2006 09:30:26 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Tuesday, 27 March 2012 18:16:06 GMT