XDV condition based on a presence of a cookie

196 views Asked by At

I'd like to create XDV rules based on a cookie condition.

Let's say that I have a cookie called "mobile" and if it's present I want to delete some stylesheet and script rules.

(BTW prototyping plone.org mobile version)

1

There are 1 answers

0
Laurence Rowe On BEST ANSWER

XDV / Diazo supports standard XSLT parameters, just add:

<xsl:param name="myvar">default value</xsl:param>

to the top level of your <rules> and you can then access the value using $myvar in if-content expressions.

Currently only Nginx provides a way to configure which parameters are passed in (see http://pypi.python.org/pypi/xdv#nginx for an example where the $path parameter is passed in.)

The Apache mod_tansform module does not have parameter support. I had some half working code for it, but it needs to gain xpath quoting support and better configuration syntax before I can merge it into the distributed mod_transform.

I would like to see tal expression to parameter mapping in plone.app.theming (the next version of collective.xdv) but I don't know when I'll get to implement it. It should be fairly simple though.

For the record I'm strongly against adding xslt extensions that would allow inline tal in xpaths.

For this use case though, I do think it is better to have a separate web and mobile domain, as you indeed advocate at http://webandmobile.mfabrik.com/docs/web-and-mobile/user-manual/redirector ;)