[opencms-dev] Text-only alternative for website howto

Joe Desbonnet jdesbonnet at gmail.com
Mon Jan 23 01:40:38 CET 2006


I've been researching the following problem and have come up with a
solution. So I'm writing up a "Howto" document, but I would like to
hear from others who may have solved the problem in a different
(perhaps better) way first.

The problem:

All pages must include a "Text-only" link which will take the user to
a version of the page rendered with a text-only template. This is to
facilitate a small, but significant number of users who cannot or
prefer not to use graphical browsers such as IE and Mozilla/Firefox.
Once a user selects the "text-only" option, all subsequent pages in
the user's session must be rendered using the text-only template until
such time the user chooses to revert to the default (graphical)
template.

The solution:

My first thought was to use cookies to remember the user's preference
for text-only template. However this requires cookies to be enabled on
the browser. Also I believe this approach is not compatible with the
use of FlexCache. Ie choosing different templates depending on the
value of a cookie is not possible while FlexCache is in operation
because FlexCache can only cache one version of a page.

My second idea was to use GET parameters. Eg to append
"?template=text" to the end of all links and to check for the
"template" parameter in the template code and render accordingly. The
problem with this technique, is that all links (including those in
HTML pages) would have to be changed on the fly to incorporate this
parameter. This technique is compatible FlexCache,  but as far as I
can tell it is not trivial to implement.

The solution I'm currently testing to create two VirtualHost entries
in the Apache httpd.conf.  (I am using Apache to serve the site as
described in  "Configure OpenCms, httpd and Tomact to serve multiple
sites" in the OpenCms manual).

The first entry is exactly as described in the manual, mapping
http://www.mysite.com/ to the OpenCms site.  The second entry is a
duplicate of the first, except the host name
is different. Eg it maps http://text.mysite.com/ to the same OpenCms
site. Obviously DNS needs to be setup to map text.mysite.com to the
Apache server.

Now I modify my template code to check for HTTP header entry "x-forwarded-host"
(mod_proxy copies the original "host" header into "x-forwarded-host").
If the host name starts with "text." I render the page with the text
template, else I render with the default template.

I am currently testing this technique and it is looking promising. 
However I'd like to hear from anyone that might have a neater solution
to his problem.

Regards,

Joe.



More information about the opencms-dev mailing list