Tips & Tricks
While XDV handles the look-and-feel of a page, it leaves the content part of the page to Plone itself. If you want to tweak something that comes from Plone most probably you will still need to customize the template on the Plone level as you do it with a regular Plone theme.
Customizing Plone templates might be not fun. But z3c.jbot (that stands for “Just a Bunch Of Templates”) comes to rescue. We will not dive into details of how to install this package - you can find this out at the product’s page. This package will add a couple of milliseconds to the overall page’s loading, but I think it is worth that.
With the package you can override pretty much any resource or template in Plone no matter whether it is a portlet, view, viewlet or just a regular ZPT.
collective.xdv’s output is XHTML 1.0 Transitional by default. You can't "read" the Doctype from your theme's index.html at the moment. Sometimes you might want to change it to another Doctype if your theme requires this. For example you want to have XHTML Strict.
To do so, we need to override standard boilerplate coming from xdv. Of course overriding the whole template is a bad idea because you will need to tune and adjust it every time the boilerplate in XDV is changed. Thus collective.xdv allows you to “extend” the standard XDV. In order to do so you will need to write XSLT, but this time it’s pretty basic and, hey, I have an example for you!
In order to override Doctype (or frankly any output feature of XDV) create a file called
extra.xsl in your theme’s root folder
with the following content:
<?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN" doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"/> </xsl:stylesheet>
This will result in
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
Once you have
extra.xsl in your theme you can let xdv transformations know where to get your extensions.
Go to the “Theme transform” configuration and add
in the “XSLT extension file” field. This will give you an output HTML with the specified Doctype.
For XHTML compatible output it is necessary to use with XHTML1.0 transitional or strict doctypes. No other doctype will trigger the compatibility mode in the xml serializer.
For HTML 5 compatible output, use of the XHTML1.0 strict doctype is recommended, as it is an "obsolete permitted doctype string"
XDV Plone theme in virtual machine
If you are using any virtual machine for testing your theme in different OS’s and browsers most probably your virtual machine will access your Plone site using a specific IP. In this case you might find that your Plone site doesn’t get theme transformations applied when viewed from your virtual machine. To solve this just add that IP (with the port most probably) to the “Domains” field of “Transform settings” configuration.
It’s always a good idea to keep the ZMI of your site on a separate domain, or access it by IP, to avoid transformations being applied to it.