Tips for collective.xdv
Some rough and ready pointers for getting collective.xdv to work.
The following points are relevant for collective.xdv 1.0b4.
The installation instructions here seem to work OK, but I recommend using Plone 3.3.* or greater.
Debug versus Production Mode
Everything will work properly in debug mode, but I've found a couple of issues in production mode. So check your work without debug mode on before you deploy it.
- In production mode, I found I needed the complete path to my theme and rules file, rather than the path relative to your instance.
- In production mode, multiple themes on multiple Plone sites didn't work, unless you tweaked the code (see below)
Multiple Themes in a Single Plone Site
If you want to style up a section of your site with a different theme from the main theme, then you can do this with the alternate themes option in the themes transforms set-up screen.
The following will style up a news folder at the root of your site
^/news(/.*)?$ | [path to theme file] | [path to rules file]
The following will style up any news folder at any point in your site
^.*/news(/.*)?$ | [path to theme file] | [path to rules file]
Multiple Themes for Multiple Sites
This is when you have a number of Plone sites in the same Zope instance, and you want each to have a theme of its own. You can only really experiment with this if you're prepared to set up Apache in front of your development instance, set up a few virtual hosts and edit the hosts file on your computer. On a Mac this turns out to be not too difficult.
- The basic instructions are here.
- There's a dashboard widget for editing your hosts file (HostsWidget).
- A rough and ready VirtualHost entry to copy at the bottom of this page.
(you'll have to do this anyway to deploy multiple sites in production - though my instructions are for a rough and ready development instance only)
You'll also need to tweak the code a bit (note if you're running in foreground mode or debug mode, you won't see the need for this tweak - but you'll soon see the point when you turn debug off).
Go to collective.xdv.transforms (you'll find this in buildout-cache/eggs at the top level of your plone installation).
At line 128 - add the line in bold
for domain in domains:
if domain.lower() == host.lower():
found_domain = True
domain_name = domain.lower()
break
if not found_domain:
At line 155/6
theme = settings.theme
rules = settings.rules
theme_id = u'default%s' % domain_name
You'll need to restart to incorporate these changes. They are just a hack - keep an eye on collective.xdv releases to see if this gets fixed.
Rough and Ready VirtualHost Entry
On a Mac you'll find a ready-made .conf file which automatically gets included in the main Apache httpd.conf here:
/private/etc/apache2/extras/httpd-vhosts.conf
The following assumes that
- you've assigned www.site2.com to 127.0.0.1 in your hosts file (or using the HostsWidget)
- you've got a Plone site in your zope instance called site2
- you've set Zope to listen at 127.0.0.1 on port 8080 (that's the default set up anyway)
Insert the following below any VirtualHost entries that are already there.
<VirtualHost *:80>
ServerAdmin webmaster@yourunit.ox.ac.uk
ServerName www.site2.com
ProxyRequests Off
# allow to connect to localhost with port ending with 80 and 90
# the having at least 2 digits before the 80 or 90
<ProxyMatch http://localhost:[0-9]{2,}?[8|9]0/.*>
Order deny,allow
Allow from all
</ProxyMatch>
# Enable/disable the handling of HTTP/1.1 "Via:" headers.
# Set to one of: Off | On | Full | Block
ProxyVia On
RewriteEngine On
RewriteRule ^($|/.*) \
http://127.0.0.1:8080/VirtualHostBase/\
http/%{SERVER_NAME}:80/site2/VirtualHostRoot$1 [L,P]
</VirtualHost>
